Category Archives: Uncategorized

Kadane’s algorithm
Leave a commentOctober 23, 2017 by oneOokay
求一个array中的continuous subarray的sum的最大值. 其实是一个dp的想法.对于当前的array[i]有两种操作: 把它和之前的以array[i1]为最后一个元素的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 
Maximum Sum of 3 NonOverlapping Subarrays
Leave a commentOctober 15, 2017 by oneOokay
In a given array nums of positive integers, find three nonoverlapping subarrays with maximum sum. Each subarray will be of size k, and …
Continue reading 
Number of Distinct Islands
Leave a commentOctober 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 
265. Paint House II
Leave a commentSeptember 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 
Longest Consecutive Sequence
Leave a commentSeptember 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 
Task Scheduler
Leave a commentSeptember 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 
HIndex
Leave a commentSeptember 25, 2017 by oneOokay
Given an array of citations (each citation is a nonnegative integer) of a researcher, write a function to compute the …
Continue reading