IncredibleThings

导航

2016年9月29日 #

HackerRank-Longest Subarray

摘要: give an array and target value, find the max length of the subarray which sum of the elements is less or equal to that value. public int longestSubArray(int[] a, int k){ if(a==null... 阅读全文

posted @ 2016-09-29 23:32 IncredibleThings 阅读(478) 评论(0) 推荐(0) 编辑

LeetCode-Combinations

摘要: Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. For example, If n = 4 and k = 2, a solution is: [ [2,4], [3,4], [2,3], [1,2], [1,3], [1,4], ] ... 阅读全文

posted @ 2016-09-29 05:43 IncredibleThings 阅读(140) 评论(0) 推荐(0) 编辑

LeetCode-Sort Colors

摘要: 我们先用两个指针,一个指向已经排好序的0的序列的后一个点,一个指向已经排好序的2的序列的前一个点。这样在一开始,两个指针是指向头和尾的,因为我们还没有开始排序。然后我们遍历数组,当遇到0时,将其和0序列后面一个数交换,然后将0序列的指针向后移。当遇到2时,将其和2序列前面一个数交换,然后将2序列的指 阅读全文

posted @ 2016-09-29 03:24 IncredibleThings 阅读(121) 评论(0) 推荐(0) 编辑

LeetCode-Search a 2D Matrix

摘要: Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: Integers in each row are sorted from left to right. The first integer of each row... 阅读全文

posted @ 2016-09-29 01:19 IncredibleThings 阅读(136) 评论(0) 推荐(0) 编辑