Category Archives: Uncategorized

  1. Kadane’s algorithm

    Leave a comment

    October 23, 2017 by oneOokay

    求一个array中的continuous subarray的sum的最大值. 其实是一个dp的想法.对于当前的array[i]有两种操作: 把它和之前的以array[i-1]为最后一个元素的subarray组合一起成一个新的subarray 以array[i]自己一个人的成一个新的subarray int[] dp : length == array.length. dp[i]表示以array[i]为最后一个元素的一个continuous array的max sum. 递推公式是: dp[i] = dp[i – 1] …
    Continue reading

  2. Maximum Sum of 3 Non-Overlapping Subarrays

    Leave a comment

    October 15, 2017 by oneOokay

    In a given array nums of positive integers, find three non-overlapping subarrays with maximum sum. Each subarray will be of size k, and …
    Continue reading

  3. Number of Distinct Islands

    Leave a comment

    October 8, 2017 by oneOokay

    问题在于如何存/translate an island so you can distinct them from each other. 我的代码跑过了所有700+个test case但是就是最后两个跑不过,而且test case太大不可能debug.最终拿了别人的pass的代码一个一个比较output才明白为什么我卡在最后两个test case了… 我的: main method里面 boolean[][] visited和String …
    Continue reading

  4. 265. Paint House II

    Leave a comment

    September 28, 2017 by oneOokay

    here are a row of n houses, each house can be painted with one of the k colors. The cost of painting each house …
    Continue reading

  5. Longest Consecutive Sequence

    Leave a comment

    September 28, 2017 by oneOokay

    Given an unsorted array of integers, find the length of the longest consecutive elements sequence. For example, Given [100, 4, 200, …
    Continue reading

  6. Task Scheduler

    Leave a comment

    September 28, 2017 by oneOokay

    Given a char array representing tasks CPU need to do. It contains capital letters A to Z where different letters …
    Continue reading

  7. H-Index

    Leave a comment

    September 25, 2017 by oneOokay

    Given an array of citations (each citation is a non-negative integer) of a researcher, write a function to compute the …
    Continue reading