随笔分类 - 算法研究
摘要:Gas StationThere areNgas stations along a circular route, where the amount of gas at stationiisgas[i].You have a car with an unlimited gas tank and it...
阅读全文
摘要:Symmetric TreeGiven a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmetric...
阅读全文
摘要:Intersection of Two Linked ListsWrite a program to find the node at which the intersection of two singly linked lists begins.For example, the followin...
阅读全文
摘要:Longest Substring Without Repeating CharactersGiven a string, find the length of the longest substring without repeating characters. For example, the ...
阅读全文
摘要:Word LadderTotal Accepted:24823Total Submissions:135014My SubmissionsGiven two words (startandend), and a dictionary, find the length of shortest tran...
阅读全文
摘要:Search Insert PositionGiven a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if ...
阅读全文
摘要:Merge Two Sorted ListsMerge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the fir...
阅读全文
摘要:Validate Binary Search TreeGiven a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtre...
阅读全文
摘要:Add BinaryGiven two binary strings, return their sum (also a binary string).For example,a ="11"b ="1"Return"100".Hide TagsMathString先补全字符串,从末尾开始加,每次计算...
阅读全文
摘要:Search a 2D MatrixWrite an efficient algorithm that searches for a value in anmxnmatrix. This matrix has the following properties:Integers in each row...
阅读全文
摘要:Find Peak ElementA peak element is an element that is greater than its neighbors.Given an input array wherenum[i] ≠ num[i+1], find a peak element and ...
阅读全文
摘要:Unique Binary Search TreesGivenn, how many structurally uniqueBST's(binary search trees) that store values 1...n?For example,Givenn= 3, there are a to...
阅读全文
摘要:Compare Version NumbersCompare two version numbersversion1andversion1.Ifversion1>version2return 1, ifversion1 22; return 1.Example2: version1=="11.22....
阅读全文
摘要:AnagramsGiven an array of strings, return all groups of strings that are anagrams.Note: All inputs will be in lower-case.Anagrams:即字母个数和字母都相同,但是字母顺序不相...
阅读全文
摘要:ZigZag ConversionThe string"PAYPALISHIRING"is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern i...
阅读全文
摘要:Maximum GapGiven an unsorted array, find the maximum difference between the successive elements in its sorted form.Try to solve it in linear time/spac...
阅读全文
摘要:Median of Two Sorted ArraysThere are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run...
阅读全文
摘要:Search for a RangeGiven a sorted array of integers, find the starting and ending position of a given target value.Your algorithm's runtime complexity ...
阅读全文
摘要:Word Ladder IIGiven two words (startandend), and a dictionary, find all shortest transformation sequence(s) fromstarttoend, such that:Only one letter ...
阅读全文
摘要:Surrounded RegionsGiven a 2D board containing'X'and'O', capture all regions surrounded by'X'.A region is captured by flipping all'O's into'X's in that...
阅读全文