自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

原创 CODE 50: Remove Duplicates from Sorted List II

Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list. For example, Give...

2013-09-29 22:44:54 470 0

原创 CODE 51: 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. Giv...

2013-09-29 22:04:44 388 0

原创 CODE 48: Maximal Rectangle

Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and return its area. public int maxima...

2013-09-28 22:06:31 324 0

原创 CODE 49:Largest Rectangle in Histogram

public int largestRectangleArea(int[] height) { // Start typing your Java solution below // DO NOT write main() function if (null == height || ...

2013-09-27 23:30:26 446 0

原创 CODE 47: 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 ...

2013-09-25 22:30:06 602 0

原创 CODE 45: 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 elemen...

2013-09-23 22:43:47 341 0

原创 CODE 44: 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...

2013-09-22 22:52:19 447 0

原创 CODE 43: Decode Ways

A message containing letters from A-Z is being encoded to numbers using the following mapping: 'A' -> 1 'B' -> 2 ... �...

2013-09-22 21:55:13 403 0

原创 CODE 40: Restore IP Addresses

Given a string containing only digits, restore it by returning all possible valid IP address combinations. For example: Given "25525511135&q...

2013-09-21 21:09:27 466 0

原创 CODE 39: Submission Details

Given a binary tree, return the inorder traversal of its nodes' values. For example: Given binary tree {1,#,2,3}, 1 \ 2 /...

2013-09-21 20:00:05 494 0

原创 CODE 46: Scramble String

Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively. Below is one possible representa...

2013-09-21 19:51:04 629 0

原创 CODE 37: 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...

2013-09-21 11:01:06 532 0

原创 CODE 38: Unique Binary Search Trees

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 uniq...

2013-09-21 10:40:34 495 0

原创 CODE 36: 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"...

2013-09-20 23:36:14 480 0

原创 CODE 35: Validate Binary Search Tree

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 contai...

2013-09-20 21:39:24 571 0

原创 CODE 26: 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)...

2013-09-20 19:38:56 621 0

原创 CODE 34: 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) sp...

2013-09-20 19:33:34 759 0

原创 CODE 33: Same Tree

Given two binary trees, write a function to check if they are equal or not. Two binary trees are considered equal if they are structurally identical...

2013-09-20 18:35:57 644 0

原创 CODE 32: 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 ...

2013-09-20 18:30:19 609 0

原创 CODE 31: 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 binar...

2013-09-20 18:08:53 594 0

原创 CODE 30: 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 leve...

2013-09-20 18:06:20 646 0

原创 CODE 29: 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 farthe...

2013-09-20 15:48:40 884 0

原创 CODE 28: 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. p...

2013-09-20 15:43:46 868 0

原创 CODE 27: 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. public...

2013-09-20 13:31:37 888 0

原创 CODE 24: 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. public TreeNode sortedListToBST(Lis...

2013-09-20 09:58:18 624 0

原创 CODE 25: Convert Sorted Array to Binary Search Tree

Given an array where elements are sorted in ascending order, convert it to a height balanced BST. public TreeNode sortedArrayToBST(int[] num) { ...

2013-09-20 09:18:09 599 0

原创 CODE 23: 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 de...

2013-09-19 21:07:00 594 0

原创 CODE 22: 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...

2013-09-19 20:16:48 618 0

原创 CODE 20: Path Sum II

public ArrayList> pathSum(TreeNode root, int sum) { // Start typing your Java solution below // DO NOT write main() function ArrayList>...

2013-09-19 19:11:32 559 0

原创 CODE 21: 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. ...

2013-09-18 23:16:25 503 0

原创 CODE 19: 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 6 ...

2013-09-17 22:31:52 478 0

原创 CODE 18: 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 ...

2013-09-17 21:16:00 442 0

原创 CODE 16: 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 ...

2013-09-16 21:23:51 619 0

原创 CODE 17: Populating Next Right Pointers in Each Node

Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; } Populate each ne...

2013-09-16 21:22:44 543 0

原创 CODE 15: 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...

2013-09-16 20:59:27 572 0

原创 CODE 9: 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, ...

2013-09-16 20:53:06 712 0

原创 CODE 2: 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 examp...

2013-09-16 20:25:58 621 0

原创 CODE 14: 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 algo...

2013-09-15 21:19:49 497 0

原创 CODE 13: 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 f...

2013-09-15 18:57:30 456 0

原创 CODE 10: 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 comp...

2013-09-15 16:57:05 759 0

提示
确定要删除当前文章?
取消 删除