12 2012 档案

[LeetCode] Remove Nth Node From End of List 解题报告
摘要:Given a linked list, remove the nth node from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2. After ... 阅读全文

posted @ 2012-12-31 14:01 小刀初试 阅读(135) 评论(0) 推荐(0) 编辑

[LeetCode] Remove Element 解题报告
摘要:Given an array and a value, remove all instances of that value in place and return the new length.The order of elements can be changed. It doesn't mat... 阅读全文

posted @ 2012-12-31 12:54 小刀初试 阅读(79) 评论(0) 推荐(0) 编辑

[LeetCode] Remove Duplicates from Sorted List 解题报告
摘要:Given a sorted linked list, delete all duplicates such that each element appear only once.For example,Given 1->1->2, return 1->2.Given 1->1->2->3->3, ... 阅读全文

posted @ 2012-12-31 12:19 小刀初试 阅读(132) 评论(0) 推荐(0) 编辑

[LeetCode] Remove Duplicates from Sorted Array II 解题报告
摘要:Follow up for "Remove Duplicates":What if duplicates are allowed at most twice?For example,Given sorted array A = [1,1,1,2,2,3],Your function should r... 阅读全文

posted @ 2012-12-31 12:00 小刀初试 阅读(126) 评论(0) 推荐(0) 编辑

[LeetCode] Remove Duplicates from Sorted Array 解题报告
摘要:Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.Do not allocate extra space for... 阅读全文

posted @ 2012-12-31 11:44 小刀初试 阅读(151) 评论(0) 推荐(0) 编辑

[LeetCode] Pow(x, n) 解题报告
摘要:Implement pow(x, n).» Solve this problem[解题思路]二分法,注意n<0的情况。[Code]1: double power(double x, int n) 2: { 3: if (n == 0) 4: return... 阅读全文

posted @ 2012-12-31 11:19 小刀初试 阅读(104) 评论(0) 推荐(0) 编辑

[LeetCode] Recover Binary Search Tree 解题报告
摘要:Two elements of a binary search tree (BST) are swapped by mistake.Recover the tree without changing its structure.Note:A solution using O(n) space is ... 阅读全文

posted @ 2012-12-31 09:46 小刀初试 阅读(102) 评论(0) 推荐(0) 编辑

[LeetCode] Populating Next Right Pointers in Each Node II 解题报告
摘要:Follow up for problem "Populating Next Right Pointers in Each Node".What if the given tree could be any binary tree? Would your previous solution stil... 阅读全文

posted @ 2012-12-30 12:33 小刀初试 阅读(121) 评论(0) 推荐(0) 编辑

[LeetCode] Populating Next Right Pointers in Each Node 解题报告
摘要:Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; }Populate each next pointe... 阅读全文

posted @ 2012-12-30 09:27 小刀初试 阅读(159) 评论(0) 推荐(0) 编辑

[LeetCode] Plus One 解题报告
摘要:Given a number represented as an array of digits, plus one to the number.» Solve this problem[解题思路]加位与进位。模拟。[Code]1: vector plusOne(vector &digits) {... 阅读全文

posted @ 2012-12-30 08:23 小刀初试 阅读(125) 评论(0) 推荐(0) 编辑

[LeetCode] Permutations II 解题报告
摘要:Given a collection of numbers that might contain duplicates, return all possible unique permutations.For example,[1,1,2] have the following unique per... 阅读全文

posted @ 2012-12-30 06:35 小刀初试 阅读(131) 评论(0) 推荐(0) 编辑

[LeetCode] Permutations 解题报告
摘要:Given a collection of numbers, return all possible permutations.For example,[1,2,3] have the following permutations:[1,2,3], [1,3,2], [2,1,3], [2,3,1]... 阅读全文

posted @ 2012-12-30 05:32 小刀初试 阅读(146) 评论(0) 推荐(0) 编辑

[LeetCode] Path Sum II 解题报告
摘要:Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.For example:Given the below binary tree and sum ... 阅读全文

posted @ 2012-12-30 04:55 小刀初试 阅读(155) 评论(0) 推荐(0) 编辑

[LeetCode] Pascal's Triangle II 解题报告
摘要:Given an index k, return the kth row of the Pascal's triangle.For example, given k = 3,Return [1,3,3,1].[ [1], [1,1], [1,2,1], [1,3,3,1], [1... 阅读全文

posted @ 2012-12-29 13:15 小刀初试 阅读(151) 评论(0) 推荐(0) 编辑

[LeetCode] Partition List 解题报告
摘要:Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x.You should preserve the o... 阅读全文

posted @ 2012-12-29 12:51 小刀初试 阅读(130) 评论(0) 推荐(0) 编辑

[LeetCode] Palindrome Number 解题报告
摘要:Determine whether an integer is a palindrome. Do this without extra space.Some hints:Could negative integers be palindromes? (ie, -1)If you are thinki... 阅读全文

posted @ 2012-12-29 12:26 小刀初试 阅读(148) 评论(0) 推荐(0) 编辑

[LeetCode] Next Permutation 解题报告
摘要:Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possibl... 阅读全文

posted @ 2012-12-28 13:46 小刀初试 阅读(167) 评论(0) 推荐(0) 编辑

[LeetCode] Multiply Strings 解题报告
摘要:Given two numbers represented as strings, return multiplication of the numbers as a string.Note: The numbers can be arbitrarily large and are non-nega... 阅读全文

posted @ 2012-12-28 12:59 小刀初试 阅读(114) 评论(0) 推荐(0) 编辑

[LeetCode] Minimum Window Substring 解题报告
摘要:Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).For example,S = "ADOBECODE... 阅读全文

posted @ 2012-12-28 10:49 小刀初试 阅读(188) 评论(0) 推荐(0) 编辑

[LeetCode] Minimum Path Sum 解题报告
摘要:Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.N... 阅读全文

posted @ 2012-12-28 07:24 小刀初试 阅读(193) 评论(0) 推荐(0) 编辑

[LeetCode] Minimum Depth of Binary Tree
摘要:Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest le... 阅读全文

posted @ 2012-12-27 13:02 小刀初试 阅读(92) 评论(0) 推荐(0) 编辑

[LeetCode] Merge Sorted Array 解题思路
摘要:Given two sorted integer arrays A and B, merge B into A as one sorted array.Note:You may assume that A has enough space to hold additional elements fr... 阅读全文

posted @ 2012-12-27 12:46 小刀初试 阅读(97) 评论(0) 推荐(0) 编辑

[LeetCode] Merge k Sorted Lists 解题报告
摘要:Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.» Solve this problem[解题思路]merge sort。外面套一层循环即可。注意指针操... 阅读全文

posted @ 2012-12-27 12:24 小刀初试 阅读(98) 评论(0) 推荐(0) 编辑

[LeetCode] Median of Two Sorted Arrays 解题报告
摘要:There are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be ... 阅读全文

posted @ 2012-12-27 11:39 小刀初试 阅读(123) 评论(0) 推荐(0) 编辑

[LeetCode] Maximum Subarray 解题报告
摘要:Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array [−2,1,−3,4,−1,2,1... 阅读全文

posted @ 2012-12-26 11:04 小刀初试 阅读(149) 评论(0) 推荐(0) 编辑

[LeetCode] Maximum Depth of Binary Tree
摘要:Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest le... 阅读全文

posted @ 2012-12-26 08:41 小刀初试 阅读(93) 评论(0) 推荐(0) 编辑

[LeetCode] Longest Substring Without Repeating Characters 解题报告
摘要:Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters fo... 阅读全文

posted @ 2012-12-25 10:03 小刀初试 阅读(124) 评论(0) 推荐(0) 编辑

[LeetCode] Longest Palindromic Substring 解题报告
摘要:Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longes... 阅读全文

posted @ 2012-12-25 08:45 小刀初试 阅读(106) 评论(0) 推荐(0) 编辑

[LeetCode] Longest Common Prefix 解题报告
摘要:Write a function to find the longest common prefix string amongst an array of strings.» Solve this problem[解题报告]又一个实现题。遍历字符串数组,每次用当前prefix和下一个字符串匹配以生成... 阅读全文

posted @ 2012-12-25 05:49 小刀初试 阅读(125) 评论(0) 推荐(0) 编辑

[LeetCode] Letter Combinations of a Phone Number 解题报告
摘要:Given a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephon... 阅读全文

posted @ 2012-12-25 03:48 小刀初试 阅读(126) 评论(0) 推荐(0) 编辑

[Leetcode] Length of Last Word 解题报告
摘要:Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.If the last word ... 阅读全文

posted @ 2012-12-24 17:31 小刀初试 阅读(172) 评论(0) 推荐(0) 编辑

[LeetCode] Largest Rectangle in Histogram 解题报告
摘要:Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the hist... 阅读全文

posted @ 2012-12-24 13:43 小刀初试 阅读(175) 评论(0) 推荐(0) 编辑

[LeetCode] Jump Game II 解题报告
摘要:Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximu... 阅读全文

posted @ 2012-12-24 07:53 小刀初试 阅读(141) 评论(0) 推荐(0) 编辑

[LeetCode] Jump Game 解题报告
摘要:Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximu... 阅读全文

posted @ 2012-12-24 06:40 小刀初试 阅读(182) 评论(0) 推荐(0) 编辑

[LeetCode] Interleaving String 解题报告
摘要:Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2.For example,Given:s1 = "aabcc",s2 = "dbbca",When s3 = "aadbbcbcac", retur... 阅读全文

posted @ 2012-12-24 06:06 小刀初试 阅读(179) 评论(0) 推荐(0) 编辑

[LeetCode] Integer to Roman 解题报告
摘要:Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.» Solve this problem[解题思路]这道题主要就在于如何处理每一位dig... 阅读全文

posted @ 2012-12-23 13:36 小刀初试 阅读(118) 评论(0) 推荐(0) 编辑

[LeetCode] Insert Interval 解题报告
摘要:Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary).You may assume that the intervals were initial... 阅读全文

posted @ 2012-12-23 12:32 小刀初试 阅读(184) 评论(0) 推荐(0) 编辑

[LeetCode] Implement strStr() 解题报告
摘要:Implement strStr().Returns a pointer to the first occurrence of needle in haystack, or null if needle is not part of haystack.» Solve this problem[解题思... 阅读全文

posted @ 2012-12-23 11:14 小刀初试 阅读(145) 评论(0) 推荐(0) 编辑

[LeetCode] Gray Code 解题报告
摘要:The gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integer n representing the total numb... 阅读全文

posted @ 2012-12-23 06:37 小刀初试 阅读(177) 评论(0) 推荐(0) 编辑

[LeetCode] Generate Parentheses 解题报告
摘要:Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set is:"((... 阅读全文

posted @ 2012-12-22 14:29 小刀初试 阅读(176) 评论(0) 推荐(0) 编辑

[LeetCode] Flatten Binary Tree to Linked List 解题报告
摘要:Given a binary tree, flatten it to a linked list in-place.For example,Given 1 / \ 2 5 / \ \ 3 4 6The flattened t... 阅读全文

posted @ 2012-12-22 11:38 小刀初试 阅读(163) 评论(0) 推荐(0) 编辑

[LeetCode] First Missing Positive 解题报告
摘要:Given an unsorted integer array, find the first missing positive integer.For example,Given [1,2,0] return 3,and [3,4,-1,1] return 2.Your algorithm sho... 阅读全文

posted @ 2012-12-21 16:40 小刀初试 阅读(129) 评论(0) 推荐(0) 编辑

[LeetCode] Edit Distance 解题报告
摘要:Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.)You have t... 阅读全文

posted @ 2012-12-21 14:35 小刀初试 阅读(147) 评论(0) 推荐(0) 编辑

[LeetCode] Divide Two Integers 解题报告
摘要:Divide two integers without using multiplication, division and mod operator.两个数的除法,但是不允许用乘、除、取余符号。[解题思路]如果可以用乘的话,二分搜索倒是不错的解法。否则,只能寄希望于位符操作了。 基本思想就是把除数... 阅读全文

posted @ 2012-12-21 04:49 小刀初试 阅读(185) 评论(0) 推荐(0) 编辑

[Leetcode] Distinct Subsequences 解题报告
摘要:Given a string S and a string T, count the number of distinct subsequences of T in S.A subsequence of a string is a new string which is formed from th... 阅读全文

posted @ 2012-12-20 08:03 小刀初试 阅读(189) 评论(0) 推荐(0) 编辑

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

点击右上角即可分享
微信分享提示