- 博客(10)
- 收藏
- 关注
原创 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 subarray [4,−1,2,1] has
2014-03-08 00:10:32
361
原创 Reorder List
Given a singly linked list L: 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' values. For example, Given {1,2,3,4}, reorder it to
2014-03-04 11:46:10
377
原创 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, 6 ], [ 7, 8
2014-03-03 01:45:59
373
原创 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 pretty straight forward. Could you devise
2014-03-01 03:16:25
494
原创 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 the tree.vector buildHashTable(vector &inorder) { int max = inord
2014-02-28 02:52:55
565
原创 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 the tree. vector buildHashTable(vector &inorder) { int max =
2014-02-28 02:38:39
525
原创 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 subtrees of every node never diffe
2014-02-23 11:38:14
351
原创 Unique Paths
A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). The robot can only move either down or right at any point in time. The robot is trying to reach the bo
2014-02-23 11:15:21
437
原创 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 leaf node. int maxDepth(TreeNode *root) {
2014-02-23 11:09:56
321
原创 CC150 p2.3 C++
2.3 Implement an algorithm to delete a node in the middle of a singly linked list, given only access to that node. Since we only have access to the node to be "deleted", we can emulate it by changing
2014-02-23 11:01:25
1185
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人