IncredibleThings

导航

上一页 1 ··· 15 16 17 18 19 20 21 22 23 ··· 28 下一页

2016年10月25日 #

LeetCode-Search in Rotated Sorted Array II

摘要: 解决方法就是对于A[mid]==A[left]和A[mid]==A[right]单独处理。 阅读全文

posted @ 2016-10-25 04:54 IncredibleThings 阅读(84) 评论(0) 推荐(0) 编辑

2016年10月5日 #

LeetCode-Search in Rotated Sorted Array

摘要: Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2). You are given a target value to search. If found in the array return its... 阅读全文

posted @ 2016-10-05 05:10 IncredibleThings 阅读(126) 评论(0) 推荐(0) 编辑

LeetCode-Remove Duplicates from Sorted Array II

摘要: 感觉这道题的oa有点问题。。。先这样吧 要in place 改变原数组: 阅读全文

posted @ 2016-10-05 03:33 IncredibleThings 阅读(91) 评论(0) 推荐(0) 编辑

LeetCode-Word Search

摘要: Given a 2D board and a word, find if the word exists in the grid. The word can be constructed from letters of sequentially adjacent cell, where "adjac 阅读全文

posted @ 2016-10-05 00:07 IncredibleThings 阅读(97) 评论(0) 推荐(0) 编辑

2016年10月1日 #

LeetCode-Subsets

摘要: 二刷: 1. 用 BFS 做 我们可以一位一位的网上叠加,比如对于题目中给的例子[1,2,3]来说,最开始是空集,那么我们现在要处理1,就在空集上加1,为[1],现在我们有两个自己[]和[1],下面我们来处理2,我们在之前的子集基础上,每个都加个2,可以分别得到[2],[1, 2],那么现在所有的子 阅读全文

posted @ 2016-10-01 05:35 IncredibleThings 阅读(164) 评论(0) 推荐(0) 编辑

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) 编辑

2016年9月28日 #

LeetCode-Set Matrix Zeroes

摘要: 二刷: 题目说明不能用额外空间,为了减少重复计算, 我们只是把等于零的相对应的头row和头column标为零。 注意第一排和列共用一个matrix[0][0], 应该分开讨论: 阅读全文

posted @ 2016-09-28 08:07 IncredibleThings 阅读(125) 评论(0) 推荐(0) 编辑

上一页 1 ··· 15 16 17 18 19 20 21 22 23 ··· 28 下一页