- 博客(59)
- 资源 (1)
- 收藏
- 关注
原创 LeetCode 95: Unique Binary Search Trees II
Difficulty: 4Frequency: 1Problem: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
2013-09-11 22:05:04
355
原创 LeetCode 99: Recover Binary Search Tree
Difficulty: 4Frequency: 2Problem: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) sp
2013-09-08 21:13:55
481
原创 LeetCode 103: Binary Tree Zigzag Level Order Traversal
Difficulty: 4Frequency: 3Problem: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 a
2013-09-08 20:15:31
414
原创 LeetCode 123: Best Time to Buy and Sell Stock III
Difficulty: 4Frequency: 2Problem: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 comp
2013-09-08 19:06:56
451
原创 LeetCode 124: Binary Tree Maximum Path Sum
Difficulty: 4Frequency: 2Problem: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,
2013-09-08 17:16:03
440
原创 LeetCode 128: Longest Consecutive Sequence
Difficulty: 4Frequency: 3Problem:Given an unsorted array of integers, find the length of the longest consecutive elements sequence.For example,Given [100, 4, 200, 1, 3, 2],The
2013-09-07 21:13:17
315
原创 LeetCode 4: Median Of Two Sorted Array
Difficulty: 5Frequency: 3Problem: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 O(log
2013-09-06 14:08:28
326
原创 LeetCode 50: Pow(x, n)
Difficulty: 3Frequency: 5Problem:Implement pow(x, n).Solution:1. Recursive solution from AnnieKim. Lots of subtleties.class Solution {public: double pow(double x, int n) {
2013-09-05 20:21:40
813
原创 LeetCode 49: Anagrams
Difficulty: 3Frequency: 4Problem:Given an array of strings, return all groups of strings that are anagrams.Note: All inputs will be in lower-case.Solution:class Solution {public
2013-09-05 19:13:23
446
原创 LeetCode 46: Permutations
Difficulty: 3Frequency: 4Problem: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],
2013-09-05 18:45:10
443
原创 LeetCode 60: Permutation Sequence
Difficulty: 5Frequency: 1Problem:The set [1,2,3,…,n] contains a total of n! unique permutations.By listing and labeling all of the permutations in order,We get the following sequ
2013-09-05 15:21:28
538
原创 LeetCode 31: Next Permutation
Difficulty: 5Frequency: 2Problem:Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possib
2013-09-05 14:26:18
498
原创 LeetCode 92: Reverse Linked List II
Difficulty: 3Frequency: 2Problem:Reverse a linked list from position m to n. Do it in-place and in one-pass.For example:Given 1->2->3->4->5->NULL, m = 2 and n = 4,return 1-
2013-09-05 09:02:19
350
原创 LeetCode 91: Decode Ways
Difficulty: 3Frequency: 4Problem:A message containing letters from A-Z is being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given an encoded me
2013-09-04 18:58:18
357
原创 LeetCode 86: Partition List
Difficulty: 3Frequency: 3Problem:Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal tox.You should preserve the
2013-09-04 16:56:05
473
原创 LeetCode 82: Remove Duplicates from Sorted List II
Difficulty: 3Frequency: 3Problem:Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.For example,Given 1-
2013-09-04 16:23:57
370
原创 LeetCode 79: Word Search
Difficulty: 3Frequency: 4Problem:Given a 2D board and a word, find if the word exists in the grid.The word can be constructed from letters of sequentially adjacent cell, where "adjac
2013-09-04 15:47:56
377
原创 LeetCode 78: Subsets
Difficulty: 3Frequency: 4Problem:Given a set of distinct integers, S, return all possible subsets.Note:Elements in a subset must be in non-descending order.The solution set
2013-09-04 15:01:16
442
原创 LeetCode 96: Unique Binary Search Tree
Difficulty: 3Frequency: 1Problem:Given n, how many structurally unique BST's (binary search trees) that store values 1...n?For example,Given n = 3, there are a total of 5 unique
2013-09-03 16:18:48
494
原创 LeetCode 98: Validate Binary Search Tree
Difficulty: 3Frequency: 5Problem:Given a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of a node contains
2013-09-03 15:49:27
431
原创 LeetCode 106: Construct Binary Tree from Inorder and Postorder Traversal
Difficulty: 3Frequency: 3Problem:Given inorder and postorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.Solution:
2013-09-03 14:37:39
658
原创 LeetCode 107: Binary Tree Level Order Traversal II
Difficulty: 3Frequency: 1Problem: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).Fo
2013-09-03 14:03:27
455
原创 LeetCode 114: Flatten Binary Tree to Linked List
Difficulty: 3Frequency: 3Problem:Given a binary tree, flatten it to a linked list in-place.For example,Given 1 / \ 2 5 / \ \ 3 4 6
2013-09-03 13:13:19
395
原创 LeetCode 116: Populating Next Right Pointers in Each Node
Difficulty: 3Frequency: 3Problem:Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; }Populate each
2013-09-03 10:18:56
420
原创 LeetCode 120: Triangle
Difficulty: 3Frequency: 1Problem: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 fo
2013-09-03 08:27:29
396
原创 LeetCode 122: Best Time to Buy and Sell Stock II
Difficulty: 3Frequency: 1Problem: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 comp
2013-09-03 08:00:44
787
原创 LeetCode 74: Search A 2D Matrix
Difficulty: 3Frequency: 3Problem:Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are
2013-09-02 20:01:38
407
原创 LeetCode 73: Set Matrix Zeroes
Difficulty: 3Frequency: 5Problem:Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place.Follow up:Did you use extra space?A straight for
2013-09-02 16:47:34
423
原创 LeetCode 64: Minimum Path Sum
Difficulty: 3Frequency: 3Problem: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.
2013-09-02 15:26:32
396
原创 LeetCode 63: Unique Paths II
Difficulty: 3Frequency: 3Problem:Follow up for "Unique Paths":Now consider if some obstacles are added to the grids. How many unique paths would there be?An obstacle and empty sp
2013-09-02 15:03:27
375
原创 LeetCode 61: Rotate List
Difficulty: 3Frequency: 2Problem:Given a list, rotate the list to the right by k places, where k is non-negative.For example:Given 1->2->3->4->5->NULL and k = 2,return 4->5->1-
2013-09-02 14:18:18
385
原创 LeetCode 59: Spiral Matrix II
Difficulty: 3Frequency: 2Problem:Given an integer n, generate a square matrix filled with elements from 1 to n2 in spiral order.For example,Given n = 3,You should return the fo
2013-09-02 13:52:37
434
原创 LeetCode 55: Jump Game
Difficulty: 3Frequency: 2Problem: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 maxim
2013-09-02 13:16:46
750
原创 LeetCode 53: Maximum Subarray
Difficulty: 3Frequency: 3Problem: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,
2013-09-01 21:37:46
564
原创 LeetCode 39: Combination Sum
Difficulty: 3Frequency: 3Problem: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
2013-09-01 20:52:56
292
原创 LeetCode 23: Merge K Sorted List
Difficulty: 3Frequency: 4Problem:Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.Solution:/** * Definition for singly-linked li
2013-09-01 17:54:43
449
原创 LeetCode 22: Generate Parentheses
Difficulty: 3Frequency: 4Problem: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:
2013-09-01 17:23:13
537
原创 LeetCode 18: 4Sum
Difficulty: 3Frequency: 2Problem:Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array
2013-09-01 16:48:30
584
原创 一道Google笔试题--关于预编译
1.2 对以下程序,正确的输出结果是#define SUB(x,y) x-y#define ACCESS_BEFORE(element,offset,value) *SUB(&element, offset)=valueint main(){ int array[10]= {1,2,3,4,5,6,7,8,9,10}; int i; ACCESS_BEFORE(array[5],
2013-09-01 14:57:52
551
原创 LeetCode 17: Letter Combinations of a Phone Number
Difficulty: 3Frequency 3Problem: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
2013-09-01 14:44:41
506
(SIGGRAPH 04)Fast Hierarchical Importance Sampling with Blue Noise Properties的源码
2008-11-14
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人