11 2015 档案
摘要:买卖股票系列 && Subarray相关题目:Best Time to Buy and Sell Stock I && II && III (IV 单独开贴)Maximum Subarray I && II为什么这些我要总结到一起呢?因为思路基本一致。题目简略:买卖股票1: 一次买卖,利润最大。买卖...
阅读全文
摘要:Rotate ListGiven a list, rotate the list to the right bykplaces, wherekis non-negative.ExampleGiven1->2->3->4->5and k =2, return4->5->1->2->3.SOLUTION...
阅读全文
摘要:Add Two NumbersYou have two numbers represented by a linked list, where each node contains a single digit. The digits are stored inreverseorder, such ...
阅读全文
摘要:Remove Duplicates from Sorted List IIGiven a sorted linked list, delete all nodes that have duplicate numbers, leaving onlydistinctnumbers from the or...
阅读全文
摘要:Reorder ListGiven a singly linked listL:L0→L1→…→Ln-1→Ln,reorder it to:L0→Ln→L1→Ln-1→L2→Ln-2→…You must do this in-place without altering the nodes' val...
阅读全文
摘要:Merge k Sorted ListsMergeksorted linked lists and return it as one sorted list.Analyze and describe its complexity.ExampleGiven lists:[ 2->4->null, ...
阅读全文
摘要:Partition ListGiven a linked list and a valuex, partition it such that all nodes less thanxcome before nodes greater than or equal tox.You should pres...
阅读全文
摘要:Insertion Sort ListSort a linked list using insertion sort.ExampleGiven1->3->2->0->null, return0->1->2->3->null.SOLUTION:插入排序的思路就是从头开始扫过去,然后遇到比当前点小的点,...
阅读全文
摘要:Reverse Linked ListReverse a linked list.ExampleFor linked list1->2->3, the reversed linked list is3->2->1ChallengeReverse it in-place and in one-pass...
阅读全文
摘要:Sort ListSort a linked list inO(nlogn) time using constant space complexity.ExampleGiven1-3->2->null, sort it to1->2->3->null.SOLUTION:这题是merge 2 sort...
阅读全文
摘要:Merge Two Sorted Lists Merge two sorted (ascending) linked lists and return it as a new sorted list. The new sorted list should be made by splicing to
阅读全文
摘要:Remove Nth Node From End of ListGiven a linked list, remove thenthnode from the end of list and return its head.ExampleGiven linked list: 1->2->3->4->...
阅读全文
摘要:Minimum Adjustment CostGiven an integer array, adjust each integers so that the difference of every adjacent integers are not greater than a given num...
阅读全文
摘要:链表的题基本可以说是基础题,不涉及算法,要熟记他的一些基本操作,基本技巧。链表的特点就是添加删除O(1),不费空间,比如重新组合一串数字,用array需要从新开一个数组,而链表不需要,只要改变指针就行。缺点是访问的时候,最坏可能到O(n)。我个人一般怕乱,所以不用双向表,就用单项表挺好的。1,dum...
阅读全文
摘要:Wildcard MatchingImplement wildcard pattern matching with support for'?'and'*'.'?'Matches any single character.'*'Matches any sequence of characters (...
阅读全文
摘要:Interleaving StringGiven three strings:s1,s2,s3, determine whethers3is formed by the interleaving ofs1ands2.ExampleFor s1 ="aabcc", s2 ="dbbca"When s3...
阅读全文
摘要:Distinct SubsequencesGiven a stringSand a stringT, count the number of distinct subsequences ofTinS.A subsequence of a string is a new string which is...
阅读全文
摘要:Longest Common SubstringGiven two strings, find the longest common substring.Return the length of it.ExampleGiven A ="ABCD", B ="CBCE", return2.NoteTh...
阅读全文
摘要:Longest Common SubsequenceGiven two strings, find the longest common subsequence (LCS).Your code should return the length ofLCS.ExampleFor"ABCD"and"ED...
阅读全文
摘要:Edit DistanceGiven two wordsword1andword2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.)...
阅读全文
摘要:Palindrome Partitioning IIGiven a strings, cutsinto some substrings such that every substring is a palindrome.Return the minimum cuts needed for a pal...
阅读全文
摘要:Longest Increasing Continuous subsequence IIGive you an integer matrix (with row size n, column size m),find the longest increasing continuous subsequ...
阅读全文
摘要:Word BreakGiven a string s and a dictionary of words dict, determine if s can be break into a space-separated sequence of one or more dictionary words...
阅读全文
摘要:TriangleGiven a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.ExampleFor example...
阅读全文
摘要:Binary Tree Postorder TraversalGiven a binary tree, return thepostordertraversal of its nodes' values.ExampleGiven binary tree{1,#,2,3}, 1 \ ...
阅读全文
摘要:Insert Node in a Binary Search TreeGiven a binary search tree and a new tree node, insert the node into the tree. You should keep the tree still be a ...
阅读全文
摘要:Minimum Depth of Binary TreeGiven a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root...
阅读全文
摘要:Binary Search Tree IteratorDesign an iterator over a binary search tree with the following rules:Elements are visited in ascending order (i.e. an in-o...
阅读全文
浙公网安备 33010602011771号