随笔分类 - LeetCode
摘要:一:Search in Sorted Array二分查找,可有重复元素,返回target所在的位置,只需返回其中一个位置,代码中的查找范围为[low,high),左闭右开,否则容易照成死循环。代码:class Solution {public: int search(vector& nums,...
阅读全文
摘要:1).2sum1.题意:找出数组中和为target的所有数对2.思路:排序数组,然后用两个指针i、j,一前一后,计算两个指针所指内容的和与target的关系,如果小于target,i右移,如果大于,j左移,否则为其中一个解3.时间复杂度:O(nlgn)+O(n)4.空间:O(1)5.代码: v...
阅读全文
摘要: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...
阅读全文
摘要: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...
阅读全文
浙公网安备 33010602011771号