随笔分类 -  LeetCode

上一页 1 ··· 5 6 7 8 9
摘要:一:Search in Sorted Array二分查找,可有重复元素,返回target所在的位置,只需返回其中一个位置,代码中的查找范围为[low,high),左闭右开,否则容易照成死循环。代码:class Solution {public: int search(vector& nums,... 阅读全文
posted @ 2015-11-12 12:21 zengzy 阅读(284) 评论(0) 推荐(0)
摘要:1).2sum1.题意:找出数组中和为target的所有数对2.思路:排序数组,然后用两个指针i、j,一前一后,计算两个指针所指内容的和与target的关系,如果小于target,i右移,如果大于,j左移,否则为其中一个解3.时间复杂度:O(nlgn)+O(n)4.空间:O(1)5.代码: v... 阅读全文
posted @ 2015-11-07 14:28 zengzy 阅读(508) 评论(0) 推荐(2)
摘要:Given a 2D board and a list of words from the dictionary, find all words in the board.Each word must be constructed from letters of sequentially adjac... 阅读全文
posted @ 2015-11-06 00:34 zengzy 阅读(992) 评论(0) 推荐(0)
摘要: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 "adjace... 阅读全文
posted @ 2015-11-05 22:41 zengzy 阅读(547) 评论(0) 推荐(0)

上一页 1 ··· 5 6 7 8 9
levels of contents