关闭

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, Given 1->2->3->3->4->4->5, return 1->2->5. Given 1->1-...
阅读(423) 评论(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. Given 1->1->2->3->3, return 1->2->3. public ListNode dele...
阅读(347) 评论(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 maximalRectangle(char[][] matrix) { // Start typing your Java sol...
阅读(292) 评论(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 || height.length <= 0) { return 0; } int max = ...
阅读(410) 评论(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 the original relative order of the nodes in each of...
阅读(564) 评论(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 elements from B. The number of elements initialized in A ...
阅读(305) 评论(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 number of bits in the code, print the sequence of ...
阅读(393) 评论(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 ... 'Z' -> 26 Given an encoded message containing digits, determine the total nu...
阅读(362) 评论(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", return ["255.255.11.135", "255.255.111.35"]. (Order ...
阅读(418) 评论(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 / 3 return [1,3,2]. Note: Recursive solutio...
阅读(431) 评论(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 representation of s1 = "great": great / \ gr ...
阅读(575) 评论(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 return all 5 unique BST's shown below. 1 3 ...
阅读(432) 评论(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 unique BST's. 1 3 3 2 1 \...
阅读(446) 评论(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", When s3 = "aadbbcbcac", return true. When s3 = "aadbbbaccc", ret...
阅读(439) 评论(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 contains only nodes with keys less than the node's key.Th...
阅读(520) 评论(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). For example: Given binary tree {3,9,20,#,#,15,7}, ...
阅读(563) 评论(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) space is pretty straight forward. Could you devise a ...
阅读(705) 评论(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 and the nodes have the same value. public...
阅读(574) 评论(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 / \ 2 2 / \ / \ 3 4 4 3 But the f...
阅读(560) 评论(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 binary tree {3,9,20,#,#,15,7}, 3 / \ 9 20 / ...
阅读(543) 评论(0)
48条 共3页1 2 3 下一页 尾页
    个人资料
    • 访问:105600次
    • 积分:2773
    • 等级:
    • 排名:第14304名
    • 原创:178篇
    • 转载:21篇
    • 译文:0篇
    • 评论:9条
    文章分类
    最新评论