Trick
文章平均质量分 61
所难
这个作者很懒,什么都没留下…
展开
-
LeetCode-Reverse Words in a String
Given an input string, reverse the string word by word.For example,Given s = "the sky is blue",return "blue is sky the".click to show clarification.Clarification:What constitutes原创 2014-07-28 11:02:49 · 513 阅读 · 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 the original string by deleting some (can be non原创 2014-08-03 13:28:07 · 308 阅读 · 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 still work?Note:You may only use constant原创 2014-08-03 12:42:44 · 317 阅读 · 0 评论 -
LeetCode-Triangle
Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the following triangle[ [2], [3,4], [原创 2014-08-01 15:00:41 · 243 阅读 · 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].Note:Could you optimize your algorithm to use only O(k) extra space?Solution:原创 2014-08-02 09:50:15 · 211 阅读 · 0 评论 -
LeetCode-Word Ladder
Given two words (start and end), and a dictionary, find the length of shortest transformation sequence from start to end, such that:Only one letter can be changed at a timeEach intermediate word m原创 2014-07-31 14:48:02 · 473 阅读 · 0 评论 -
LeetCode-Sum Root to Leaf Numbers
Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number.An example is the root-to-leaf path 1->2->3 which represents the number 123.Find the to原创 2014-07-31 12:51:15 · 225 阅读 · 0 评论 -
LeetCode-Surrounded Regions
Given 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 surrounded region.For example,X X X XX O O X原创 2014-07-31 11:13:17 · 235 阅读 · 0 评论 -
LeetCode-Word Break II
Given a string s and a dictionary of words dict, add spaces in s to construct a sentence where each word is a valid dictionary word.Return all such possible sentences.For example, givens = "原创 2014-07-29 15:37:05 · 482 阅读 · 0 评论 -
LeetCode-Copy List with Random Pointer
A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null.Return a deep copy of the list.Solution:Code:/** * D原创 2014-07-29 16:25:10 · 366 阅读 · 0 评论 -
LeetCode-Candy
There are N children standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following requirements:Each child must have at least on原创 2014-07-30 09:46:38 · 280 阅读 · 0 评论 -
LeetCode-Single Number II
Given an array of integers, every element appears three times except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement it without usi原创 2014-07-29 22:28:02 · 397 阅读 · 0 评论 -
LeetCode-Palindrome Partitioning II
Given a string s, partition s such that every substring of the partition is a palindrome.Return the minimum cuts needed for a palindrome partitioning of s.For example, given s = "aab",Return原创 2014-07-30 13:36:12 · 216 阅读 · 0 评论 -
LeetCode-Gas Station
There are N gas stations along a circular route, where the amount of gas at station i is gas[i].You have a car with an unlimited gas tank and it costs cost[i] of gas to travel from station i to原创 2014-07-30 10:11:10 · 367 阅读 · 0 评论 -
LeetCode-Binary Tree Preorder Traversal
Given a binary tree, return the preorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [1,2,3].Note: Recursive soluti原创 2014-07-28 22:21:21 · 259 阅读 · 0 评论 -
LeetCode-Insertion Sort List
Sort a linked list using insertion sort.Solution:Code:原创 2014-07-28 16:11:29 · 261 阅读 · 0 评论 -
LeetCode-Sort List
Sort a linked list in O(n log n) time using constant space complexity.Solution:Merge Sort原创 2014-07-28 14:56:19 · 417 阅读 · 0 评论 -
LeetCode-Symmetric Tree
Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmetric: 1 / \ 2 2 / \ / \3 4 4 3But the f原创 2014-08-04 15:18:11 · 315 阅读 · 0 评论