LeetCode
文章平均质量分 67
a83610312
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
[LeetCode]Jump Game II、Jump Game
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 maximum jump length at that posit原创 2013-08-05 23:11:15 · 1217 阅读 · 0 评论 -
Triangle
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],原创 2013-09-03 19:48:02 · 706 阅读 · 0 评论 -
Pascal's Triangle、Pascal's Triangle II
Pascal's Triangle:Given numRows, generate the first numRows of Pascal's triangle.For example, given numRows = 5,Return[ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1]]原创 2013-09-03 19:23:14 · 3180 阅读 · 0 评论 -
Populating Next Right Pointers in Each Node、Populating Next Right Pointers in Each Node II
Populating Next Right Pointers in Each Node:Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; }Populate原创 2013-09-03 19:16:00 · 662 阅读 · 0 评论 -
[LeetCode] Distinct Subsequences
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 str原创 2013-08-29 12:49:04 · 617 阅读 · 0 评论 -
[LeetCode] Sort Colors
Sort Colors:Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue.Here, we wi原创 2013-08-18 21:15:23 · 1000 阅读 · 0 评论 -
[LeetCode] Construct Binary Tree from Inorder and Postorder Traversal
Construct Binary Tree from Inorder and Postorder Traversal:Given inorder and postorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in原创 2013-08-28 15:37:08 · 945 阅读 · 0 评论 -
[LeetCode] Maximum Subarray、Edit Distance
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,−5,4],the contiguous原创 2013-08-08 22:06:08 · 960 阅读 · 0 评论 -
[LeetCode] Add Two Numbers、Divide Two Integers、Multiply Strings、Add Binary、Plus One
You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a link原创 2013-07-24 23:41:41 · 1072 阅读 · 0 评论 -
[LeetCode] Path Sum II
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 = 22, 5原创 2013-08-28 17:11:21 · 571 阅读 · 0 评论 -
[LeetCode] Convert Sorted List to Binary Search Tree
Convert Sorted List to Binary Search Tree:Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST./** * Definition for singly-linked lis原创 2013-08-28 16:37:50 · 633 阅读 · 0 评论 -
[LeetCode] Binary Tree Level Order Traversal II
Binary Tree Level Order Traversal II:Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root).For原创 2013-08-28 16:19:27 · 570 阅读 · 0 评论 -
[LeetCode] Construct Binary Tree from Preorder and Inorder Traversal
Construct Binary Tree from Preorder and Inorder Traversal:Given preorder and inorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in th原创 2013-08-28 15:23:21 · 881 阅读 · 0 评论 -
[LeetCode] Flatten Binary Tree to Linked List
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原创 2013-08-28 17:23:13 · 614 阅读 · 0 评论 -
[LeetCode] Path Sum
Path Sum:Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.For example:Given the below bin原创 2013-08-28 17:04:42 · 583 阅读 · 0 评论 -
Minimum Depth of Binary Tree
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 leaf node.原创 2013-08-28 16:47:43 · 666 阅读 · 0 评论 -
[LeetCode] Balanced Binary Tree
Balanced Binary Tree:Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtr原创 2013-08-28 16:42:13 · 689 阅读 · 0 评论 -
[LeetCode] Convert Sorted Array to Binary Search Tree
Convert Sorted Array to Binary Search Tree:Given an array where elements are sorted in ascending order, convert it to a height balanced BST.愣是把 (end+begin) >> 1 写成 (end-begin)>>1, 然后想半天错在哪原创 2013-08-28 16:29:45 · 606 阅读 · 0 评论 -
Best Time to Buy and Sell Stock
Best Time to Buy and Sell Stock:Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (ie,原创 2013-09-03 19:52:43 · 819 阅读 · 0 评论 -
Best Time to Buy and Sell Stock II
Best Time to Buy and Sell Stock II:Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete原创 2013-09-03 20:12:52 · 1392 阅读 · 0 评论 -
[LeetCode] Next Permutation、Permutations、Permutations II、Permutation Sequence
Next Permutation:Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possible, it must rearrange it原创 2013-07-30 20:28:28 · 3004 阅读 · 0 评论 -
[Leetcode] Word Break、Word BreakII
Word BreakGiven a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words.For example, givens = "leetcode",原创 2013-10-19 13:42:43 · 7859 阅读 · 0 评论 -
[LeetCode] Simplify Path
Simplify Path:Given an absolute path for a file (Unix-style), simplify it.For example,path = "/home/", => "/home"path = "/a/./b/../../c/", => "/c"Corner Cases:Did you原创 2013-08-17 19:35:41 · 2088 阅读 · 0 评论 -
[LeetCode] Palindrome Partitioning II
Palindrome Partitioning IIGiven 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原创 2013-10-08 22:56:22 · 760 阅读 · 0 评论 -
[LeetCode] Palindrome Partitioning
Palindrome Partitioning Given a string s, partition s such that every substring of the partition is a palindrome.Return all possible palindrome partitioning of s.For example, given原创 2013-10-08 23:05:23 · 892 阅读 · 0 评论 -
[LeetCode] Substring with Concatenation of All Words
Substring with Concatenation of All Words You are given a string, S, and a list of words, L, that are all of the same length. Find all starting indices of substring(s) in S that is a conca原创 2013-09-23 11:33:51 · 2376 阅读 · 0 评论 -
[LeetCode] Spiral Matrix、Rotate Image、Spiral Matrix II、Set Matrix Zeroes、Search a 2D Matrix
Spiral Matrix:Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.For example,Given the following matrix:[ [ 1, 2, 3 ], [ 4, 5,原创 2013-08-10 09:48:03 · 1130 阅读 · 0 评论 -
[LeetCode] Combination Sum、Combination Sum II
Combination Sum:Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.The same repeated number may be ch原创 2013-07-30 22:04:40 · 2485 阅读 · 0 评论 -
[LeetCode] Single Number II
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原创 2013-10-06 16:15:26 · 1957 阅读 · 1 评论 -
[LeetCode] Copy List with Random Pointer
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 t原创 2013-10-05 15:56:04 · 965 阅读 · 0 评论 -
[LeetCode] Merge k Sorted Lists
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.写cmp的时候,第一反应居然是去特例化一个greater,然后发现编译通过不,不能修改greater,然后自己写一个functor,结果忘了是继承binary_function还是binary_p原创 2013-07-28 11:54:45 · 1828 阅读 · 0 评论 -
[LeetCode] Unique Binary Search Trees II
Given n, generate all structurally unique BST's (binary search trees) that store values 1...n.For example,Given n = 3, your program should return all 5 unique BST's shown below. 1 3原创 2013-10-02 16:05:34 · 685 阅读 · 0 评论 -
[LeetCode] Length of Last Word
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 does not exist, re原创 2013-08-10 12:15:25 · 604 阅读 · 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 longest palindromic substring.之前写过一篇讲这个问题,但忘记当时有原创 2013-07-27 11:08:31 · 645 阅读 · 0 评论 -
Valid Palindrome
Valid Palindrome:Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example,"A man, a plan, a canal: Panama" is a palindrome."race a car原创 2013-09-03 21:18:22 · 947 阅读 · 0 评论 -
Binary Tree Maximum Path Sum
Binary Tree Maximum Path Sum:Given a binary tree, find the maximum path sum.The path may start and end at any node in the tree.For example:Given the below binary tree, 1原创 2013-09-03 21:06:53 · 1555 阅读 · 0 评论 -
Best Time to Buy and Sell Stock III
Best Time to Buy and Sell Stock III:Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complet原创 2013-09-03 20:24:42 · 1076 阅读 · 0 评论 -
[LeetCode] Binary Tree Zigzag Level Order Traversal
Binary Tree Zigzag Level Order Traversal:Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and原创 2013-08-28 13:37:30 · 742 阅读 · 0 评论 -
[LeetCode] Interleaving String
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", return tr原创 2013-08-27 16:59:01 · 1406 阅读 · 1 评论 -
[LeetCode] Binary Tree Level Order Traversal
Binary Tree Level Order Traversal:Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).For example:Given binary tree {3,原创 2013-08-27 21:57:16 · 597 阅读 · 0 评论
分享