leetcode 150道题目的原题

leetcode 的150道题目,用脚本导出的,方便平时练习。

1:https://oj.leetcode.com/problems/reverse-words-in-a-string/

name:Reverse Words in a String    date:2014-03-05    rate:14.0%
Reverse Words in a String Total Accepted: 34174 Total Submissions: 244099 My Submissions
Given an input string, reverse the string word by word. For example, Given s = "the sky is blue", return "blue is sky the". click to show clarification. Clarification: What constitutes a word? A sequence of non-space characters constitutes a word. Could the input string contain leading or trailing spaces? Yes. However, your reversed string should not contain leading or trailing spaces. How about multiple spaces between two words? Reduce them to a single space in the reversed string.
-----------------------------------------------
2:https://oj.leetcode.com/problems/evaluate-reverse-polish-notation/
name:Evaluate Reverse Polish Notation    date:2013-11-27    rate:19.8%
Evaluate Reverse Polish Notation Total Accepted: 24966 Total Submissions: 125931 My Submissions
Evaluate the value of an arithmetic expression in Reverse Polish Notation. Valid operators are +, -, *, /. Each operand may be an integer or another expression. Some examples:  
  ["2", "1", "+", "3", "*"] -> ((2 + 1) * 3) -> 9
  ["4", "13", "5", "/", "+"] -> (4 + (13 / 5)) -> 6
-----------------------------------------------
3:https://oj.leetcode.com/problems/max-points-on-a-line/
name:Max Points on a Line    date:2013-11-22    rate:11.0%
Max Points on a Line Total Accepted: 19925 Total Submissions: 181591 My Submissions
Given n points on a 2D plane, find the maximum number of points that lie on the same straight line.
-----------------------------------------------
4:https://oj.leetcode.com/problems/sort-list/
name:Sort List    date:2013-11-16    rate:20.5%
Sort List Total Accepted: 21918 Total Submissions: 107028 My Submissions
Sort a linked list in O(n log n) time using constant space complexity.
-----------------------------------------------
5:https://oj.leetcode.com/problems/insertion-sort-list/
name:Insertion Sort List    date:2013-11-12    rate:25.3%
Insertion Sort List Total Accepted: 22390 Total Submissions: 88577 My Submissions
Sort a linked list using insertion sort.
-----------------------------------------------
6:https://oj.leetcode.com/problems/lru-cache/
name:LRU Cache    date:2013-11-09    rate:14.0%
LRU Cache Total Accepted: 18525 Total Submissions: 131928 My Submissions
Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and set. get(key) - Get the value (will always be positive) of the key if the key exists in the cache, otherwise return -1. set(key, value) - Set or insert the value if the key is not already present. When the cache reached its capacity, it should invalidate the least recently used item before inserting a new item.
-----------------------------------------------
7:https://oj.leetcode.com/problems/binary-tree-postorder-traversal/
name:Binary Tree Postorder Traversal    date:2013-11-07    rate:31.0%
Binary Tree Postorder Traversal Total Accepted: 31462 Total Submissions: 101562 My Submissions
Given a binary tree, return the postorder traversal of its nodes' values. For example: Given binary tree {1,#,2,3},  
   1
    \
     2
    /
   3
 return [3,2,1]. Note: Recursive solution is trivial, could you do it iteratively?
-----------------------------------------------
8:https://oj.leetcode.com/problems/binary-tree-preorder-traversal/
name:Binary Tree Preorder Traversal    date:2013-11-05    rate:35.7%
Binary Tree Preorder Traversal Total Accepted: 34769 Total Submissions: 97338 My Submissions
Given a binary tree, return the preorder traversal of its nodes' values. For example: Given binary tree {1,#,2,3},  
   1
    \
     2
    /
   3
 return [1,2,3]. Note: Recursive solution is trivial, could you do it iteratively?
-----------------------------------------------
9:https://oj.leetcode.com/problems/reorder-list/
name:Reorder List    date:2013-11-02    rate:20.3%
Reorder List Total Accepted: 20667 Total Submissions: 101652 My Submissions
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 {1,4,2,3}.
-----------------------------------------------
10:https://oj.leetcode.com/problems/linked-list-cycle-ii/
name:Linked List Cycle II    date:2013-10-30    rate:30.9%
Linked List Cycle II Total Accepted: 23019 Total Submissions: 74473 My Submissions
Given a linked list, return the node where the cycle begins. If there is no cycle, return null. Follow up: Can you solve it without using extra space?
-----------------------------------------------
11:https://oj.leetcode.com/problems/linked-list-cycle/
name:Linked List Cycle    date:2013-10-28    rate:35.9%
Linked List Cycle Total Accepted: 31351 Total Submissions: 87303 My Submissions
Given a linked list, determine if it has a cycle in it. Follow up: Can you solve it without using extra space?
-----------------------------------------------
12:https://oj.leetcode.com/problems/word-break-ii/
name:Word Break II    date:2013-10-05    rate:16.5%
Word Break II Total Accepted: 16230 Total Submissions: 98407 My Submissions
Given a string s and a dictionary of words dict, add spaces in s to construct a sentence where each word is a valid dictionary word. Return all such possible sentences. For example, given s = "catsanddog", dict = ["cat", "cats", "and", "sand", "dog"]. A solution is ["cats and dog", "cat sand dog"].
-----------------------------------------------
13:https://oj.leetcode.com/problems/word-break/
name:Word Break    date:2013-10-04    rate:21.2%
Word Break Total Accepted: 23804 Total Submissions: 112362 My Submissions
Given 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, given s = "leetcode", dict = ["leet", "code"]. Return true because "leetcode" can be segmented as "leet code".
-----------------------------------------------
14:https://oj.leetcode.com/problems/copy-list-with-random-pointer/
name:Copy List with Random Pointer    date:2013-10-03    rate:23.3%
Copy List with Random Pointer Total Accepted: 19943 Total Submissions: 85594 My Submissions
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 the list.
-----------------------------------------------
15:https://oj.leetcode.com/problems/single-number-ii/
name:Single Number II    date:2013-10-02    rate:33.9%
Single Number II Total Accepted: 26495 Total Submissions: 78211 My Submissions
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 you implement it without using extra memory?
-----------------------------------------------
16:https://oj.leetcode.com/problems/single-number/
name:Single Number    date:2013-10-01    rate:46.0%
Single Number Total Accepted: 36191 Total Submissions: 78760 My Submissions
Given an array of integers, every element appears twice except for one. Find that single one. Note: Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory?
-----------------------------------------------
17:https://oj.leetcode.com/problems/candy/
name:Candy    date:2013-09-30    rate:19.0%
Candy Total Accepted: 18708 Total Submissions: 98268 My Submissions
There are N children standing in a line. Each child is assigned a rating value. You are giving candies to these children subjected to the following requirements: Each child must have at least one candy. Children with a higher rating get more candies than their neighbors. What is the minimum candies you must give?
-----------------------------------------------
18:https://oj.leetcode.com/problems/gas-station/
name:Gas Station    date:2013-09-28    rate:25.8%
Gas Station Total Accepted: 20642 Total Submissions: 80061 My Submissions
There are N gas stations along a circular route, where the amount of gas at station i is gas[i]. You have a car with an unlimited gas tank and it costs cost[i] of gas to travel from station i to its next station (i+1). You begin the journey with an empty tank at one of the gas stations. Return the starting gas station's index if you can travel around the circuit once, otherwise return -1. Note: The solution is guaranteed to be unique.
-----------------------------------------------
19:https://oj.leetcode.com/problems/clone-graph/
name:Clone Graph    date:2013-09-24    rate:22.9%
Clone Graph Total Accepted: 17542 Total Submissions: 76721 My Submissions
Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors. OJ's undirected graph serialization: Nodes are labeled uniquely. We use # as a separator for each node, and , as a separator for node label and each neighbor of the node. As an example, consider the serialized graph {0,1,2#1,2#2,2}. The graph has a total of three nodes, and therefore contains three parts as separated by #. First node is labeled as 0. Connect node 0 to both nodes 1 and 2. Second node is labeled as 1. Connect node 1 to node 2. Third node is labeled as 2. Connect node 2 to node 2 (itself), thus forming a self-cycle. Visually, the graph looks like the following:  
       1
      / \
     /   \
    0 --- 2
         / \
         \_/
-----------------------------------------------
20:https://oj.leetcode.com/problems/palindrome-partitioning-ii/
name:Palindrome Partitioning II    date:2013-02-28    rate:18.2%
Palindrome Partitioning II Total Accepted: 15945 Total Submissions: 87765 My Submissions
Given 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. For example, given s = "aab", Return 1 since the palindrome partitioning ["aa","b"] could be produced using 1 cut.
-----------------------------------------------
21:https://oj.leetcode.com/problems/palindrome-partitioning/
name:Palindrome Partitioning    date:2013-02-27    rate:26.0%
Palindrome Partitioning Total Accepted: 19334 Total Submissions: 74357 My Submissions
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 s = "aab", Return  
  [
    ["aa","b"],
    ["a","a","b"]
  ]
-----------------------------------------------
22:https://oj.leetcode.com/problems/surrounded-regions/
name:Surrounded Regions    date:2013-02-21    rate:14.2%
Surrounded Regions Total Accepted: 13936 Total Submissions: 98021 My Submissions
Given a 2D board containing 'X' and 'O', capture all regions surrounded by 'X'. A region is captured by flipping all 'O's into 'X's in that surrounded region. For example,  
X X X X
X O O X
X X O X
X O X X
 After running your function, the board should be:  
X X X X
X X X X
X X X X
X O X X
-----------------------------------------------
23:https://oj.leetcode.com/problems/sum-root-to-leaf-numbers/
name:Sum Root to Leaf Numbers    date:2013-02-18    rate:29.7%
Sum Root to Leaf Numbers Total Accepted: 21998 Total Submissions: 74086 My Submissions
Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number. An example is the root-to-leaf path 1->2->3 which represents the number 123. Find the total sum of all root-to-leaf numbers. For example,  
    1
   / \
  2   3
 The root-to-leaf path 1->2 represents the number 12. The root-to-leaf path 1->3 represents the number 13. Return the sum = 12 + 13 = 25.
-----------------------------------------------
24:https://oj.leetcode.com/problems/longest-consecutive-sequence/
name:Longest Consecutive Sequence    date:2013-02-13    rate:28.2%
Longest Consecutive Sequence Total Accepted: 20702 Total Submissions: 73537 My Submissions
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 longest consecutive elements sequence is [1, 2, 3, 4]. Return its length: 4. Your algorithm should run in O(n) complexity.
-----------------------------------------------
25:https://oj.leetcode.com/problems/word-ladder-ii/
name:Word Ladder II    date:2013-02-10    rate:11.4%
Word Ladder II Total Accepted: 11173 Total Submissions: 98022 My Submissions
Given two words (start and end), and a dictionary, find all shortest transformation sequence(s) from start to end, such that: Only one letter can be changed at a time Each intermediate word must exist in the dictionary For example, Given: start = "hit" end = "cog" dict = ["hot","dot","dog","lot","log"] Return  
  [
    ["hit","hot","dot","dog","cog"],
    ["hit","hot","lot","log","cog"]
  ]
 Note: All words have the same length. All words contain only lowercase alphabetic characters.
-----------------------------------------------
26:https://oj.leetcode.com/problems/word-ladder/
name:Word Ladder    date:2013-02-10    rate:18.3%
Word Ladder Total Accepted: 18572 Total Submissions: 101373 My Submissions
Given two words (start and end), and a dictionary, find the length of shortest transformation sequence from start to end, such that: Only one letter can be changed at a time Each intermediate word must exist in the dictionary For example, Given: start = "hit" end = "cog" dict = ["hot","dot","dog","lot","log"] As one shortest transformation is "hit" -> "hot" -> "dot" -> "dog" -> "cog", return its length 5. Note: Return 0 if there is no such transformation sequence. All words have the same length. All words contain only lowercase alphabetic characters.
-----------------------------------------------
27:https://oj.leetcode.com/problems/valid-palindrome/
name:Valid Palindrome    date:2013-01-12    rate:22.9%
Valid Palindrome Total Accepted: 20559 Total Submissions: 89588 My Submissions
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" is not a palindrome. Note: Have you consider that the string might be empty? This is a good question to ask during an interview. For the purpose of this problem, we define empty string as valid palindrome.
-----------------------------------------------
28:https://oj.leetcode.com/problems/binary-tree-maximum-path-sum/
name:Binary Tree Maximum Path Sum    date:2012-11-07    rate:20.0%
Binary Tree Maximum Path Sum Total Accepted: 19694 Total Submissions: 98300 My Submissions
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
      / \
     2   3
 Return 6.
-----------------------------------------------
29:https://oj.leetcode.com/problems/best-time-to-buy-and-sell-stock-iii/
name:Best Time to Buy and Sell Stock III    date:2012-11-06    rate:22.3%
Best Time to Buy and Sell Stock III Total Accepted: 15719 Total Submissions: 70473 My Submissions
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 at most two transactions. Note: You may not engage in multiple transactions at the same time (ie, you must sell the stock before you buy again).
-----------------------------------------------
30:https://oj.leetcode.com/problems/best-time-to-buy-and-sell-stock-ii/
name:Best Time to Buy and Sell Stock II    date:2012-10-30    rate:36.8%
Best Time to Buy and Sell Stock II Total Accepted: 23845 Total Submissions: 64866 My Submissions
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 as many transactions as you like (ie, buy one and sell one share of the stock multiple times). However, you may not engage in multiple transactions at the same time (ie, you must sell the stock before you buy again).
-----------------------------------------------
31:https://oj.leetcode.com/problems/best-time-to-buy-and-sell-stock/
name:Best Time to Buy and Sell Stock    date:2012-10-30    rate:31.1%
Best Time to Buy and Sell Stock Total Accepted: 23973 Total Submissions: 77095 My Submissions
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, buy one and sell one share of the stock), design an algorithm to find the maximum profit.
-----------------------------------------------
32:https://oj.leetcode.com/problems/triangle/
name:Triangle    date:2012-10-29    rate:26.8%
Triangle Total Accepted: 18621 Total Submissions: 69524 My Submissions
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],
    [3,4],
   [6,5,7],
  [4,1,8,3]
]
 The minimum path sum from top to bottom is 11 (i.e., 2 + 3 + 5 + 1 = 11). Note: Bonus point if you are able to do this using only O(n) extra space, where n is the total number of rows in the triangle.
-----------------------------------------------
33:https://oj.leetcode.com/problems/pascals-triangle-ii/
name:Pascal's Triangle II    date:2012-10-28    rate:30.5%
Pascal's Triangle II Total Accepted: 17564 Total Submissions: 57551 My Submissions
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 algorithm to use only O(k) extra space?
-----------------------------------------------
34:https://oj.leetcode.com/problems/pascals-triangle/
name:Pascal's Triangle    date:2012-10-28    rate:31.6%
Pascal's Triangle Total Accepted: 19670 Total Submissions: 62283 My Submissions
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]
]
-----------------------------------------------
35:https://oj.leetcode.com/problems/populating-next-right-pointers-in-each-node-ii/
name:Populating Next Right Pointers in Each Node II    date:2012-10-28    rate:30.5%
Populating Next Right Pointers in Each Node II Total Accepted: 18311 Total Submissions: 60024 My Submissions
Follow up for problem "Populating Next Right Pointers in Each Node". What if the given tree could be any binary tree? Would your previous solution still work? Note: You may only use constant extra space. For example, Given the following binary tree,  
         1
       /  \
      2    3
     / \    \
    4   5    7
 After calling your function, the tree should look like:  
         1 -> NULL
       /  \
      2 -> 3 -> NULL
     / \    \
    4-> 5 -> 7 -> NULL
-----------------------------------------------
36:https://oj.leetcode.com/problems/populating-next-right-pointers-in-each-node/
name:Populating Next Right Pointers in Each Node    date:2012-10-28    rate:35.3%
Populating Next Right Pointers in Each Node Total Accepted: 24936 Total Submissions: 70589 My Submissions
Given a binary tree  
    struct TreeLinkNode {
      TreeLinkNode *left;
      TreeLinkNode *right;
      TreeLinkNode *next;
    }
 Populate each next pointer to point to its next right node. If there is no next right node, the next pointer should be set to NULL. Initially, all next pointers are set to NULL. Note: You may only use constant extra space. You may assume that it is a perfect binary tree (ie, all leaves are at the same level, and every parent has two children). For example, Given the following perfect binary tree,  
         1
       /  \
      2    3
     / \  / \
    4  5  6  7
 After calling your function, the tree should look like:  
         1 -> NULL
       /  \
      2 -> 3 -> NULL
     / \  / \
    4->5->6->7 -> NULL
-----------------------------------------------
37:https://oj.leetcode.com/problems/distinct-subsequences/
name:Distinct Subsequences    date:2012-10-18    rate:24.9%
Distinct Subsequences Total Accepted: 15931 Total Submissions: 64097 My Submissions
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 string by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters. (ie, "ACE" is a subsequence of "ABCDE" while "AEC" is not). Here is an example: S = "rabbbit", T = "rabbit" Return 3.
-----------------------------------------------
38:https://oj.leetcode.com/problems/flatten-binary-tree-to-linked-list/
name:Flatten Binary Tree to Linked List    date:2012-10-14    rate:28.1%
Flatten Binary Tree to Linked List Total Accepted: 23006 Total Submissions: 81765 My Submissions
Given a binary tree, flatten it to a linked list in-place. For example, Given  
         1
        / \
       2   5
      / \   \
     3   4   6
 The flattened tree should look like:  
   1
    \
     2
      \
       3
        \
         4
          \
           5
            \
             6
 click to show hints. Hints: If you notice carefully in the flattened tree, each node's right child points to the next node of a pre-order traversal.
-----------------------------------------------
39:https://oj.leetcode.com/problems/path-sum-ii/
name:Path Sum II    date:2012-10-14    rate:27.0%
Path Sum II Total Accepted: 20581 Total Submissions: 76232 My Submissions
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
             / \
            4   8
           /   / \
          11  13  4
         /  \    / \
        7    2  5   1
 return  
[
   [5,4,11,2],
   [5,8,4,5]
]
-----------------------------------------------
40:https://oj.leetcode.com/problems/path-sum/
name:Path Sum    date:2012-10-13    rate:30.7%
Path Sum Total Accepted: 22768 Total Submissions: 74207 My Submissions
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 binary tree and sum = 22,  
              5
             / \
            4   8
           /   / \
          11  13  4
         /  \      \
        7    2      1
 return true, as there exist a root-to-leaf path 5->4->11->2 which sum is 22.
-----------------------------------------------
41:https://oj.leetcode.com/problems/minimum-depth-of-binary-tree/
name:Minimum Depth of Binary Tree    date:2012-10-09    rate:29.6%
Minimum Depth of Binary Tree Total Accepted: 23583 Total Submissions: 79632 My Submissions
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.
-----------------------------------------------
42:https://oj.leetcode.com/problems/balanced-binary-tree/
name:Balanced Binary Tree    date:2012-10-08    rate:32.8%
Balanced Binary Tree Total Accepted: 25076 Total Submissions: 76517 My Submissions
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 differ by more than 1.
-----------------------------------------------
43:https://oj.leetcode.com/problems/convert-sorted-list-to-binary-search-tree/
name:Convert Sorted List to Binary Search Tree    date:2012-10-02    rate:27.4%
Convert Sorted List to Binary Search Tree Total Accepted: 19658 Total Submissions: 71842 My Submissions
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.
-----------------------------------------------
44:https://oj.leetcode.com/problems/convert-sorted-array-to-binary-search-tree/
name:Convert Sorted Array to Binary Search Tree    date:2012-10-02    rate:32.8%
Convert Sorted Array to Binary Search Tree Total Accepted: 21214 Total Submissions: 64671 My Submissions
Given an array where elements are sorted in ascending order, convert it to a height balanced BST.
-----------------------------------------------
45:https://oj.leetcode.com/problems/binary-tree-level-order-traversal-ii/
name:Binary Tree Level Order Traversal II    date:2012-10-01    rate:31.4%
Binary Tree Level Order Traversal II Total Accepted: 18566 Total Submissions: 59157 My Submissions
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},  
    3
   / \
  9  20
    /  \
   15   7
 return its bottom-up level order traversal as:  
[
  [15,7],
  [9,20],
  [3]
]
 confused what "{1,#,2,3}" means? > read more on how binary tree is serialized on OJ. OJ's Binary Tree Serialization: The serialization of a binary tree follows a level order traversal, where '#' signifies a path terminator where no node exists below. Here's an example:  
   1
  / \
 2   3
    /
   4
    \
     5
 The above binary tree is serialized as "{1,2,3,#,#,4,#,#,5}".
-----------------------------------------------
46:https://oj.leetcode.com/problems/construct-binary-tree-from-inorder-and-postorder-traversal/
name:Construct Binary Tree from Inorder and Postorder Traversal    date:2012-09-30    rate:26.6%
Construct Binary Tree from Inorder and Postorder Traversal Total Accepted: 15266 Total Submissions: 57452 My Submissions
Given inorder and postorder traversal of a tree, construct the binary tree. Note: You may assume that duplicates do not exist in the tree.
-----------------------------------------------
47:https://oj.leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/
name:Construct Binary Tree from Preorder and Inorder Traversal    date:2012-09-30    rate:26.6%
Construct Binary Tree from Preorder and Inorder Traversal Total Accepted: 15831 Total Submissions: 59527 My Submissions
Given preorder and inorder traversal of a tree, construct the binary tree. Note: You may assume that duplicates do not exist in the tree.
-----------------------------------------------
48:https://oj.leetcode.com/problems/maximum-depth-of-binary-tree/
name:Maximum Depth of Binary Tree    date:2012-09-29    rate:44.0%
Maximum Depth of Binary Tree Total Accepted: 30654 Total Submissions: 69726 My Submissions
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.
-----------------------------------------------
49:https://oj.leetcode.com/problems/binary-tree-zigzag-level-order-traversal/
name:Binary Tree Zigzag Level Order Traversal    date:2012-09-28    rate:26.7%
Binary Tree Zigzag Level Order Traversal Total Accepted: 16216 Total Submissions: 60825 My Submissions
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 alternate between). For example: Given binary tree {3,9,20,#,#,15,7},  
    3
   / \
  9  20
    /  \
   15   7
 return its zigzag level order traversal as:  
[
  [3],
  [20,9],
  [15,7]
]
 confused what "{1,#,2,3}" means? > read more on how binary tree is serialized on OJ. OJ's Binary Tree Serialization: The serialization of a binary tree follows a level order traversal, where '#' signifies a path terminator where no node exists below. Here's an example:  
   1
  / \
 2   3
    /
   4
    \
     5
 The above binary tree is serialized as "{1,2,3,#,#,4,#,#,5}".
-----------------------------------------------
50:https://oj.leetcode.com/problems/binary-tree-level-order-traversal/
name:Binary Tree Level Order Traversal    date:2012-09-28    rate:30.8%
Binary Tree Level Order Traversal Total Accepted: 22481 Total Submissions: 72874 My Submissions
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
    /  \
   15   7
 return its level order traversal as:  
[
  [3],
  [9,20],
  [15,7]
]
 confused what "{1,#,2,3}" means? > read more on how binary tree is serialized on OJ. OJ's Binary Tree Serialization: The serialization of a binary tree follows a level order traversal, where '#' signifies a path terminator where no node exists below. Here's an example:  
   1
  / \
 2   3
    /
   4
    \
     5
 The above binary tree is serialized as "{1,2,3,#,#,4,#,#,5}".
-----------------------------------------------
51:https://oj.leetcode.com/problems/symmetric-tree/
name:Symmetric Tree    date:2012-09-23    rate:32.3%
Symmetric Tree Total Accepted: 25223 Total Submissions: 78111 My Submissions
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 following is not:  
    1
   / \
  2   2
   \   \
   3    3
 Note: Bonus points if you could solve it both recursively and iteratively. confused what "{1,#,2,3}" means? > read more on how binary tree is serialized on OJ. OJ's Binary Tree Serialization: The serialization of a binary tree follows a level order traversal, where '#' signifies a path terminator where no node exists below. Here's an example:  
   1
  / \
 2   3
    /
   4
    \
     5
 The above binary tree is serialized as "{1,2,3,#,#,4,#,#,5}".
-----------------------------------------------
52:https://oj.leetcode.com/problems/same-tree/
name:Same Tree    date:2012-09-03    rate:42.1%
Same Tree Total Accepted: 29126 Total Submissions: 69250 My Submissions
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.
-----------------------------------------------
53:https://oj.leetcode.com/problems/recover-binary-search-tree/
name:Recover Binary Search Tree    date:2012-09-01    rate:23.7%
Recover Binary Search Tree Total Accepted: 16181 Total Submissions: 68383 My Submissions
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 constant space solution? confused what "{1,#,2,3}" means? > read more on how binary tree is serialized on OJ. OJ's Binary Tree Serialization: The serialization of a binary tree follows a level order traversal, where '#' signifies a path terminator where no node exists below. Here's an example:  
   1
  / \
 2   3
    /
   4
    \
     5
 The above binary tree is serialized as "{1,2,3,#,#,4,#,#,5}".
-----------------------------------------------
54:https://oj.leetcode.com/problems/validate-binary-search-tree/
name:Validate Binary Search Tree    date:2012-08-31    rate:25.9%
Validate Binary Search Tree Total Accepted: 21702 Total Submissions: 83809 My Submissions
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. The right subtree of a node contains only nodes with keys greater than the node's key. Both the left and right subtrees must also be binary search trees. confused what "{1,#,2,3}" means? > read more on how binary tree is serialized on OJ. OJ's Binary Tree Serialization: The serialization of a binary tree follows a level order traversal, where '#' signifies a path terminator where no node exists below. Here's an example:  
   1
  / \
 2   3
    /
   4
    \
     5
 The above binary tree is serialized as "{1,2,3,#,#,4,#,#,5}".
-----------------------------------------------
55:https://oj.leetcode.com/problems/interleaving-string/
name:Interleaving String    date:2012-08-30    rate:19.4%
Interleaving String Total Accepted: 15495 Total Submissions: 80053 My Submissions
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", return false.
-----------------------------------------------
56:https://oj.leetcode.com/problems/unique-binary-search-trees-ii/
name:Unique Binary Search Trees II    date:2012-08-27    rate:27.3%
Unique Binary Search Trees II Total Accepted: 14318 Total Submissions: 52372 My Submissions
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     3      2      1
    \       /     /      / \      \
     3     2     1      1   3      2
    /     /       \                 \
   2     1         2                 3
 confused what "{1,#,2,3}" means? > read more on how binary tree is serialized on OJ. OJ's Binary Tree Serialization: The serialization of a binary tree follows a level order traversal, where '#' signifies a path terminator where no node exists below. Here's an example:  
   1
  / \
 2   3
    /
   4
    \
     5
 The above binary tree is serialized as "{1,2,3,#,#,4,#,#,5}".
-----------------------------------------------
57:https://oj.leetcode.com/problems/unique-binary-search-trees/
name:Unique Binary Search Trees    date:2012-08-27    rate:36.6%
Unique Binary Search Trees Total Accepted: 24815 Total Submissions: 67754 My Submissions
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
    \       /     /      / \      \
     3     2     1      1   3      2
    /     /       \                 \
   2     1         2                 3
-----------------------------------------------
58:https://oj.leetcode.com/problems/binary-tree-inorder-traversal/
name:Binary Tree Inorder Traversal    date:2012-08-27    rate:35.6%
Binary Tree Inorder Traversal Total Accepted: 31765 Total Submissions: 89122 My Submissions
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 solution is trivial, could you do it iteratively? confused what "{1,#,2,3}" means? > read more on how binary tree is serialized on OJ. OJ's Binary Tree Serialization: The serialization of a binary tree follows a level order traversal, where '#' signifies a path terminator where no node exists below. Here's an example:  
   1
  / \
 2   3
    /
   4
    \
     5
 The above binary tree is serialized as "{1,2,3,#,#,4,#,#,5}".
-----------------------------------------------
59:https://oj.leetcode.com/problems/restore-ip-addresses/
name:Restore IP Addresses    date:2012-08-07    rate:20.5%
Restore IP Addresses Total Accepted: 14929 Total Submissions: 72764 My Submissions
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 does not matter)
-----------------------------------------------
60:https://oj.leetcode.com/problems/reverse-linked-list-ii/
name:Reverse Linked List II    date:2012-06-27    rate:26.1%
Reverse Linked List II Total Accepted: 18981 Total Submissions: 72811 My Submissions
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->4->3->2->5->NULL. Note: Given m, n satisfy the following condition: 1 ≤ m ≤ n ≤ length of list.
-----------------------------------------------
61:https://oj.leetcode.com/problems/subsets-ii/
name:Subsets II    date:2012-06-25    rate:27.1%
Subsets II Total Accepted: 17592 Total Submissions: 65028 My Submissions
Given a collection of integers that might contain duplicates, S, return all possible subsets. Note: Elements in a subset must be in non-descending order. The solution set must not contain duplicate subsets. For example, If S = [1,2,2], a solution is:  
[
  [2],
  [1],
  [1,2,2],
  [2,2],
  [1,2],
  []
]
-----------------------------------------------
62:https://oj.leetcode.com/problems/decode-ways/
name:Decode Ways    date:2012-06-25    rate:16.1%
Decode Ways Total Accepted: 16564 Total Submissions: 102756 My Submissions
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 number of ways to decode it. For example, Given encoded message "12", it could be decoded as "AB" (1 2) or "L" (12). The number of ways decoding "12" is 2.
-----------------------------------------------
63:https://oj.leetcode.com/problems/gray-code/
name:Gray Code    date:2012-05-20    rate:32.1%
Gray Code Total Accepted: 16781 Total Submissions: 52314 My Submissions
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 gray code. A gray code sequence must begin with 0. For example, given n = 2, return [0,1,3,2]. Its gray code sequence is:  
00 - 0
01 - 1
11 - 3
10 - 2
 Note: For a given n, a gray code sequence is not uniquely defined. For example, [0,2,3,1] is also a valid gray code sequence according to the above definition. For now, the judge is able to judge based on one instance of gray code sequence. Sorry about that.
-----------------------------------------------
64:https://oj.leetcode.com/problems/merge-sorted-array/
name:Merge Sorted Array    date:2012-05-20    rate:32.2%
Merge Sorted Array Total Accepted: 23723 Total Submissions: 73653 My Submissions
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 (size that is greater or equal to m + n) to hold additional elements from B. The number of elements initialized in A and B are m and n respectively.
-----------------------------------------------
65:https://oj.leetcode.com/problems/scramble-string/
name:Scramble String    date:2012-04-30    rate:22.7%
Scramble String Total Accepted: 13443 Total Submissions: 59201 My Submissions
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    eat
 / \    /  \
g   r  e   at
           / \
          a   t
 To scramble the string, we may choose any non-leaf node and swap its two children. For example, if we choose the node "gr" and swap its two children, it produces a scrambled string "rgeat".  
    rgeat
   /    \
  rg    eat
 / \    /  \
r   g  e   at
           / \
          a   t
 We say that "rgeat" is a scrambled string of "great". Similarly, if we continue to swap the children of nodes "eat" and "at", it produces a scrambled string "rgtae".  
    rgtae
   /    \
  rg    tae
 / \    /  \
r   g  ta  e
       / \
      t   a
 We say that "rgtae" is a scrambled string of "great". Given two strings s1 and s2 of the same length, determine if s2 is a scrambled string of s1.
-----------------------------------------------
66:https://oj.leetcode.com/problems/partition-list/
name:Partition List    date:2012-04-30    rate:26.9%
Partition List Total Accepted: 18147 Total Submissions: 67382 My Submissions
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 the two partitions. For example, Given 1->4->3->2->5->2 and x = 3, return 1->2->2->4->3->5.
-----------------------------------------------
67:https://oj.leetcode.com/problems/maximal-rectangle/
name:Maximal Rectangle    date:2012-04-23    rate:21.6%
Maximal Rectangle Total Accepted: 11792 Total Submissions: 54589 My Submissions
Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and return its area.
-----------------------------------------------
68:https://oj.leetcode.com/problems/largest-rectangle-in-histogram/
name:Largest Rectangle in Histogram    date:2012-04-22    rate:21.4%
Largest Rectangle in Histogram Total Accepted: 16727 Total Submissions: 78113 My Submissions
Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the histogram. Above is a histogram where width of each bar is 1, given height = [2,1,5,6,2,3]. The largest rectangle is shown in the shaded area, which has area = 10 unit. For example, Given height = [2,1,5,6,2,3], return 10.
-----------------------------------------------
69:https://oj.leetcode.com/problems/remove-duplicates-from-sorted-list-ii/
name:Remove Duplicates from Sorted List II    date:2012-04-22    rate:24.9%
Remove Duplicates from Sorted List II Total Accepted: 19945 Total Submissions: 80213 My Submissions
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->1->2->3, return 2->3.
-----------------------------------------------
70:https://oj.leetcode.com/problems/remove-duplicates-from-sorted-list/
name:Remove Duplicates from Sorted List    date:2012-04-22    rate:35.2%
Remove Duplicates from Sorted List Total Accepted: 27171 Total Submissions: 77185 My Submissions
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.
-----------------------------------------------
71:https://oj.leetcode.com/problems/search-in-rotated-sorted-array-ii/
name:Search in Rotated Sorted Array II    date:2012-04-19    rate:30.8%
Search in Rotated Sorted Array II Total Accepted: 16997 Total Submissions: 55210 My Submissions
Follow up for "Search in Rotated Sorted Array": What if duplicates are allowed? Would this affect the run-time complexity? How and why? Write a function to determine if a given target is in the array.
-----------------------------------------------
72:https://oj.leetcode.com/problems/remove-duplicates-from-sorted-array-ii/
name:Remove Duplicates from Sorted Array II    date:2012-04-19    rate:30.7%
Remove Duplicates from Sorted Array II Total Accepted: 19884 Total Submissions: 64751 My Submissions
Follow up for "Remove Duplicates": What if duplicates are allowed at most twice? For example, Given sorted array A = [1,1,1,2,2,3], Your function should return length = 5, and A is now [1,1,2,2,3].
-----------------------------------------------
73:https://oj.leetcode.com/problems/word-search/
name:Word Search    date:2012-04-18    rate:19.9%
Word Search Total Accepted: 15460 Total Submissions: 77713 My Submissions
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 "adjacent" cells are those horizontally or vertically neighboring. The same letter cell may not be used more than once. For example, Given board =  
[
  ["ABCE"],
  ["SFCS"],
  ["ADEE"]
]
 word = "ABCCED", -> returns true, word = "SEE", -> returns true, word = "ABCB", -> returns false.
-----------------------------------------------
74:https://oj.leetcode.com/problems/subsets/
name:Subsets    date:2012-04-18    rate:27.8%
Subsets Total Accepted: 22670 Total Submissions: 81484 My Submissions
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 must not contain duplicate subsets. For example, If S = [1,2,3], a solution is:  
[
  [3],
  [1],
  [2],
  [1,2,3],
  [1,3],
  [2,3],
  [1,2],
  []
]
-----------------------------------------------
75:https://oj.leetcode.com/problems/combinations/
name:Combinations    date:2012-04-18    rate:30.3%
Combinations Total Accepted: 20553 Total Submissions: 67789 My Submissions
Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. For example, If n = 4 and k = 2, a solution is:  
[
  [2,4],
  [3,4],
  [2,3],
  [1,2],
  [1,3],
  [1,4],
]
-----------------------------------------------
76:https://oj.leetcode.com/problems/minimum-window-substring/
name:Minimum Window Substring    date:2012-04-15    rate:18.1%
Minimum Window Substring Total Accepted: 14236 Total Submissions: 78777 My Submissions
Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n). For example, S = "ADOBECODEBANC" T = "ABC" Minimum window is "BANC". Note: If there is no such window in S that covers all characters in T, return the emtpy string "". If there are multiple such windows, you are guaranteed that there will always be only one unique minimum window in S.
-----------------------------------------------
77:https://oj.leetcode.com/problems/sort-colors/
name:Sort Colors    date:2012-04-08    rate:32.1%
Sort Colors Total Accepted: 23996 Total Submissions: 74708 My Submissions
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 will use the integers 0, 1, and 2 to represent the color red, white, and blue respectively. Note: You are not suppose to use the library's sort function for this problem. click to show follow up. Follow up: A rather straight forward solution is a two-pass algorithm using counting sort. First, iterate the array counting number of 0's, 1's, and 2's, then overwrite array with total number of 0's, then 1's and followed by 2's. Could you come up with an one-pass algorithm using only constant space?
-----------------------------------------------
78:https://oj.leetcode.com/problems/search-a-2d-matrix/
name:Search a 2D Matrix    date:2012-04-06    rate:31.2%
Search a 2D Matrix Total Accepted: 20154 Total Submissions: 64594 My Submissions
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 sorted from left to right. The first integer of each row is greater than the last integer of the previous row. For example, Consider the following matrix:  
[
  [1,   3,  5,  7],
  [10, 11, 16, 20],
  [23, 30, 34, 50]
]
 Given target = 3, return true.
-----------------------------------------------
79:https://oj.leetcode.com/problems/set-matrix-zeroes/
name:Set Matrix Zeroes    date:2012-04-05    rate:30.9%
Set Matrix Zeroes Total Accepted: 17654 Total Submissions: 57138 My Submissions
Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place. click to show follow up. Follow up: Did you use extra space? A straight forward solution using O(mn) space is probably a bad idea. A simple improvement uses O(m + n) space, but still not the best solution. Could you devise a constant space solution?
-----------------------------------------------
80:https://oj.leetcode.com/problems/edit-distance/
name:Edit Distance    date:2012-04-04    rate:25.3%
Edit Distance Total Accepted: 15420 Total Submissions: 60856 My Submissions
Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.) You have the following 3 operations permitted on a word: a) Insert a character b) Delete a character c) Replace a character
-----------------------------------------------
81:https://oj.leetcode.com/problems/simplify-path/
name:Simplify Path    date:2012-04-03    rate:19.9%
Simplify Path Total Accepted: 12487 Total Submissions: 62601 My Submissions
Given an absolute path for a file (Unix-style), simplify it. For example, path = "/home/", => "/home" path = "/a/./b/../../c/", => "/c" click to show corner cases. Corner Cases: Did you consider the case where path = "/../"? In this case, you should return "/". Another corner case is the path might contain multiple slashes '/' together, such as "/home//foo/". In this case, you should ignore redundant slashes and return "/home/foo".
-----------------------------------------------
82:https://oj.leetcode.com/problems/climbing-stairs/
name:Climbing Stairs    date:2012-04-03    rate:34.1%
Climbing Stairs Total Accepted: 24096 Total Submissions: 70752 My Submissions
You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?
-----------------------------------------------
83:https://oj.leetcode.com/problems/sqrtx/
name:Sqrt(x)    date:2012-04-03    rate:22.3%
Sqrt(x) Total Accepted: 23641 Total Submissions: 105943 My Submissions
Implement int sqrt(int x). Compute and return the square root of x.
-----------------------------------------------
84:https://oj.leetcode.com/problems/text-justification/
name:Text Justification    date:2012-04-03    rate:14.0%
Text Justification Total Accepted: 9018 Total Submissions: 64188 My Submissions
Given an array of words and a length L, format the text such that each line has exactly L characters and is fully (left and right) justified. You should pack your words in a greedy approach; that is, pack as many words as you can in each line. Pad extra spaces ' ' when necessary so that each line has exactly L characters. Extra spaces between words should be distributed as evenly as possible. If the number of spaces on a line do not divide evenly between words, the empty slots on the left will be assigned more spaces than the slots on the right. For the last line of text, it should be left justified and no extra space is inserted between words. For example, words: ["This", "is", "an", "example", "of", "text", "justification."] L: 16. Return the formatted lines as:  
[
   "This    is    an",
   "example  of text",
   "justification.  "
]
 Note: Each word is guaranteed not to exceed L in length. click to show corner cases. Corner Cases: A line other than the last line might contain only one word. What should you do in this case? In this case, that line should be left-justified.
-----------------------------------------------
85:https://oj.leetcode.com/problems/plus-one/
name:Plus One    date:2012-04-02    rate:31.7%
Plus One Total Accepted: 19844 Total Submissions: 62688 My Submissions
Given a non-negative number represented as an array of digits, plus one to the number. The digits are stored such that the most significant digit is at the head of the list.
-----------------------------------------------
86:https://oj.leetcode.com/problems/valid-number/
name:Valid Number    date:2012-04-02    rate:11.1%
Valid Number Total Accepted: 11605 Total Submissions: 104749 My Submissions
Validate if a given string is numeric. Some examples: "0" => true " 0.1 " => true "abc" => false "1 a" => false "2e10" => true Note: It is intended for the problem statement to be ambiguous. You should gather all requirements up front before implementing one.
-----------------------------------------------
87:https://oj.leetcode.com/problems/add-binary/
name:Add Binary    date:2012-04-02    rate:26.0%
Add Binary Total Accepted: 17525 Total Submissions: 67379 My Submissions
Given two binary strings, return their sum (also a binary string). For example, a = "11" b = "1" Return "100".
-----------------------------------------------
88:https://oj.leetcode.com/problems/merge-two-sorted-lists/
name:Merge Two Sorted Lists    date:2012-03-30    rate:33.3%
Merge Two Sorted Lists Total Accepted: 25214 Total Submissions: 75669 My Submissions
Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.
-----------------------------------------------
89:https://oj.leetcode.com/problems/minimum-path-sum/
name:Minimum Path Sum    date:2012-03-28    rate:31.3%
Minimum Path Sum Total Accepted: 17777 Total Submissions: 56864 My Submissions
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. Note: You can only move either down or right at any point in time.
-----------------------------------------------
90:https://oj.leetcode.com/problems/unique-paths-ii/
name:Unique Paths II    date:2012-03-28    rate:27.9%
Unique Paths II Total Accepted: 15377 Total Submissions: 55184 My Submissions
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 space is marked as 1 and 0 respectively in the grid. For example, There is one obstacle in the middle of a 3x3 grid as illustrated below.  
[
  [0,0,0],
  [0,1,0],
  [0,0,0]
]
 The total number of unique paths is 2. Note: m and n will be at most 100.
-----------------------------------------------
91:https://oj.leetcode.com/problems/unique-paths/
name:Unique Paths    date:2012-03-28    rate:31.6%
Unique Paths Total Accepted: 20193 Total Submissions: 63918 My Submissions
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 bottom-right corner of the grid (marked 'Finish' in the diagram below). How many possible unique paths are there? Above is a 3 x 7 grid. How many possible unique paths are there? Note: m and n will be at most 100.
-----------------------------------------------
92:https://oj.leetcode.com/problems/rotate-list/
name:Rotate List    date:2012-03-27    rate:22.1%
Rotate List Total Accepted: 16912 Total Submissions: 76478 My Submissions
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->2->3->NULL.
-----------------------------------------------
93:https://oj.leetcode.com/problems/permutation-sequence/
name:Permutation Sequence    date:2012-03-27    rate:22.2%
Permutation Sequence Total Accepted: 13622 Total Submissions: 61331 My Submissions
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 sequence (ie, for n = 3): "123" "132" "213" "231" "312" "321" Given n and k, return the kth permutation sequence. Note: Given n will be between 1 and 9 inclusive.
-----------------------------------------------
94:https://oj.leetcode.com/problems/spiral-matrix-ii/
name:Spiral Matrix II    date:2012-03-27    rate:30.8%
Spiral Matrix II Total Accepted: 14109 Total Submissions: 45845 My Submissions
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 following matrix:  
[
 [ 1, 2, 3 ],
 [ 8, 9, 4 ],
 [ 7, 6, 5 ]
]
-----------------------------------------------
95:https://oj.leetcode.com/problems/length-of-last-word/
name:Length of Last Word    date:2012-03-27    rate:29.5%
Length of Last Word Total Accepted: 18858 Total Submissions: 64014 My Submissions
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, return 0. Note: A word is defined as a character sequence consists of non-space characters only. For example, Given s = "Hello World", return 5.
-----------------------------------------------
96:https://oj.leetcode.com/problems/insert-interval/
name:Insert Interval    date:2012-03-27    rate:20.7%
Insert Interval Total Accepted: 15546 Total Submissions: 75238 My Submissions
Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary). You may assume that the intervals were initially sorted according to their start times. Example 1: Given intervals [1,3],[6,9], insert and merge [2,5] in as [1,5],[6,9]. Example 2: Given [1,2],[3,5],[6,7],[8,10],[12,16], insert and merge [4,9] in as [1,2],[3,10],[12,16]. This is because the new interval [4,9] overlaps with [3,5],[6,7],[8,10].
-----------------------------------------------
97:https://oj.leetcode.com/problems/merge-intervals/
name:Merge Intervals    date:2012-03-26    rate:20.9%
Merge Intervals Total Accepted: 16100 Total Submissions: 77162 My Submissions
Given a collection of intervals, merge all overlapping intervals. For example, Given [1,3],[2,6],[8,10],[15,18], return [1,6],[8,10],[15,18].
-----------------------------------------------
98:https://oj.leetcode.com/problems/jump-game/
name:Jump Game    date:2012-03-24    rate:27.2%
Jump Game Total Accepted: 20013 Total Submissions: 73507 My Submissions
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 position. Determine if you are able to reach the last index. For example: A = [2,3,1,1,4], return true. A = [3,2,1,0,4], return false.
-----------------------------------------------
99:https://oj.leetcode.com/problems/spiral-matrix/
name:Spiral Matrix    date:2012-03-24    rate:20.6%
Spiral Matrix Total Accepted: 14205 Total Submissions: 68858 My Submissions
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, 9 ]
]
 You should return [1,2,3,6,9,8,7,4,5].
-----------------------------------------------
100:https://oj.leetcode.com/problems/maximum-subarray/
name:Maximum Subarray    date:2012-03-21    rate:33.8%
Maximum Subarray Total Accepted: 25920 Total Submissions: 76642 My Submissions
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 the largest sum = 6. click to show more practice. More practice: If you have figured out the O(n) solution, try coding another solution using the divide and conquer approach, which is more subtle.
-----------------------------------------------
101:https://oj.leetcode.com/problems/n-queens-ii/
name:N-Queens II    date:2012-03-20    rate:33.5%
N-Queens II Total Accepted: 13501 Total Submissions: 40357 My Submissions
Follow up for N-Queens problem. Now, instead outputting board configurations, return the total number of distinct solutions.
-----------------------------------------------
102:https://oj.leetcode.com/problems/n-queens/
name:N-Queens    date:2012-03-19    rate:25.9%
N-Queens Total Accepted: 15032 Total Submissions: 57952 My Submissions
The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other. Given an integer n, return all distinct solutions to the n-queens puzzle. Each solution contains a distinct board configuration of the n-queens' placement, where 'Q' and '.' both indicate a queen and an empty space respectively. For example, There exist two distinct solutions to the 4-queens puzzle:  
[
 [".Q..",  // Solution 1
  "...Q",
  "Q...",
  "..Q."],
 
 ["..Q.",  // Solution 2
  "Q...",
  "...Q",
  ".Q.."]
]
-----------------------------------------------
103:https://oj.leetcode.com/problems/powx-n/
name:Pow(x, n)    date:2012-03-19    rate:25.9%
Pow(x, n) Total Accepted: 23045 Total Submissions: 89023 My Submissions
Implement pow(x, n).
-----------------------------------------------
104:https://oj.leetcode.com/problems/anagrams/
name:Anagrams    date:2012-03-19    rate:23.8%
Anagrams Total Accepted: 15807 Total Submissions: 66318 My Submissions
Given an array of strings, return all groups of strings that are anagrams. Note: All inputs will be in lower-case.
-----------------------------------------------
105:https://oj.leetcode.com/problems/rotate-image/
name:Rotate Image    date:2012-03-17    rate:31.4%
Rotate Image Total Accepted: 17466 Total Submissions: 55653 My Submissions
You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise). Follow up: Could you do this in-place?
-----------------------------------------------
106:https://oj.leetcode.com/problems/permutations-ii/
name:Permutations II    date:2012-03-16    rate:25.1%
Permutations II Total Accepted: 17025 Total Submissions: 67822 My Submissions
Given a collection of numbers that might contain duplicates, return all possible unique permutations. For example, [1,1,2] have the following unique permutations: [1,1,2], [1,2,1], and [2,1,1].
-----------------------------------------------
107:https://oj.leetcode.com/problems/permutations/
name:Permutations    date:2012-03-16    rate:31.4%
Permutations Total Accepted: 24503 Total Submissions: 78136 My Submissions
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], [2,3,1], [3,1,2], and [3,2,1].
-----------------------------------------------
108:https://oj.leetcode.com/problems/jump-game-ii/
name:Jump Game II    date:2012-03-16    rate:24.7%
Jump Game II Total Accepted: 17335 Total Submissions: 70174 My Submissions
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 position. Your goal is to reach the last index in the minimum number of jumps. For example: Given array A = [2,3,1,1,4] The minimum number of jumps to reach the last index is 2. (Jump 1 step from index 0 to 1, then 3 steps to the last index.)
-----------------------------------------------
109:https://oj.leetcode.com/problems/wildcard-matching/
name:Wildcard Matching    date:2012-03-15    rate:13.9%
Wildcard Matching Total Accepted: 13156 Total Submissions: 94642 My Submissions
Implement wildcard pattern matching with support for '?' and '*'.  
'?' Matches any single character.
'*' Matches any sequence of characters (including the empty sequence).
 
The matching should cover the entire input string (not partial).
 
The function prototype should be:
bool isMatch(const char *s, const char *p)
 
Some examples:
isMatch("aa","a") → false
isMatch("aa","aa") → true
isMatch("aaa","aa") → false
isMatch("aa", "*") → true
isMatch("aa", "a*") → true
isMatch("ab", "?*") → true
isMatch("aab", "c*a*b") → false
-----------------------------------------------
110:https://oj.leetcode.com/problems/multiply-strings/
name:Multiply Strings    date:2012-03-12    rate:20.6%
Multiply Strings Total Accepted: 13689 Total Submissions: 66541 My Submissions
Given two numbers represented as strings, return multiplication of the numbers as a string. Note: The numbers can be arbitrarily large and are non-negative.
-----------------------------------------------
111:https://oj.leetcode.com/problems/trapping-rain-water/
name:Trapping Rain Water    date:2012-03-10    rate:28.8%
Trapping Rain Water Total Accepted: 16486 Total Submissions: 57170 My Submissions
Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining. For example, Given [0,1,0,2,1,0,1,3,2,1,2,1], return 6. The above elevation map is represented by array [0,1,0,2,1,0,1,3,2,1,2,1]. In this case, 6 units of rain water (blue section) are being trapped. Thanks Marcos for contributing this image!
-----------------------------------------------
112:https://oj.leetcode.com/problems/first-missing-positive/
name:First Missing Positive    date:2012-03-08    rate:22.6%
First Missing Positive Total Accepted: 17506 Total Submissions: 77474 My Submissions
Given an unsorted integer array, find the first missing positive integer. For example, Given [1,2,0] return 3, and [3,4,-1,1] return 2. Your algorithm should run in O(n) time and uses constant space.
-----------------------------------------------
113:https://oj.leetcode.com/problems/combination-sum-ii/
name:Combination Sum II    date:2012-03-06    rate:24.6%
Combination Sum II Total Accepted: 15232 Total Submissions: 61880 My Submissions
Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T. Each number in C may only be used once in the combination. Note: All numbers (including target) will be positive integers. Elements in a combination (a1, a2, … , ak) must be in non-descending order. (ie, a1 ≤ a2 ≤ … ≤ ak). The solution set must not contain duplicate combinations. For example, given candidate set 10,1,2,7,6,1,5 and target 8, A solution set is: [1, 7] [1, 2, 5] [2, 6] [1, 1, 6]
-----------------------------------------------
114:https://oj.leetcode.com/problems/combination-sum/
name:Combination Sum    date:2012-03-06    rate:26.6%
Combination Sum Total Accepted: 19270 Total Submissions: 72387 My Submissions
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 chosen from C unlimited number of times. Note: All numbers (including target) will be positive integers. Elements in a combination (a1, a2, … , ak) must be in non-descending order. (ie, a1 ≤ a2 ≤ … ≤ ak). The solution set must not contain duplicate combinations. For example, given candidate set 2,3,6,7 and target 7, A solution set is: [7] [2, 2, 3]
-----------------------------------------------
115:https://oj.leetcode.com/problems/count-and-say/
name:Count and Say    date:2012-03-05    rate:27.3%
Count and Say Total Accepted: 15618 Total Submissions: 57195 My Submissions
The count-and-say sequence is the sequence of integers beginning as follows: 1, 11, 21, 1211, 111221, ... 1 is read off as "one 1" or 11. 11 is read off as "two 1s" or 21. 21 is read off as "one 2, then one 1" or 1211. Given an integer n, generate the nth sequence. Note: The sequence of integers will be represented as a string.
-----------------------------------------------
116:https://oj.leetcode.com/problems/sudoku-solver/
name:Sudoku Solver    date:2012-03-04    rate:20.8%
Sudoku Solver Total Accepted: 12698 Total Submissions: 61050 My Submissions
Write a program to solve a Sudoku puzzle by filling the empty cells. Empty cells are indicated by the character '.'. You may assume that there will be only one unique solution. A sudoku puzzle... ...and its solution numbers marked in red.
-----------------------------------------------
117:https://oj.leetcode.com/problems/valid-sudoku/
name:Valid Sudoku    date:2012-03-03    rate:27.9%
Valid Sudoku Total Accepted: 14165 Total Submissions: 50683 My Submissions
Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules. The Sudoku board could be partially filled, where empty cells are filled with the character '.'. A partially filled sudoku which is valid. Note: A valid Sudoku board (partially filled) is not necessarily solvable. Only the filled cells need to be validated.
-----------------------------------------------
118:https://oj.leetcode.com/problems/search-insert-position/
name:Search Insert Position    date:2012-03-03    rate:35.0%
Search Insert Position Total Accepted: 26250 Total Submissions: 74915 My Submissions
Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. You may assume no duplicates in the array. Here are few examples. [1,3,5,6], 5 → 2 [1,3,5,6], 2 → 1 [1,3,5,6], 7 → 4 [1,3,5,6], 0 → 0
-----------------------------------------------
119:https://oj.leetcode.com/problems/search-for-a-range/
name:Search for a Range    date:2012-03-02    rate:27.5%
Search for a Range Total Accepted: 19813 Total Submissions: 72005 My Submissions
Given a sorted array of integers, find the starting and ending position of a given target value. Your algorithm's runtime complexity must be in the order of O(log n). If the target is not found in the array, return [-1, -1]. For example, Given [5, 7, 7, 8, 8, 10] and target value 8, return [3, 4].
-----------------------------------------------
120:https://oj.leetcode.com/problems/search-in-rotated-sorted-array/
name:Search in Rotated Sorted Array    date:2012-03-02    rate:28.6%
Search in Rotated Sorted Array Total Accepted: 25894 Total Submissions: 90635 My Submissions
Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2). You are given a target value to search. If found in the array return its index, otherwise return -1. You may assume no duplicate exists in the array.
-----------------------------------------------
121:https://oj.leetcode.com/problems/longest-valid-parentheses/
name:Longest Valid Parentheses    date:2012-02-29    rate:19.6%
Longest Valid Parentheses Total Accepted: 15980 Total Submissions: 81691 My Submissions
Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring. For "(()", the longest valid parentheses substring is "()", which has length = 2. Another example is ")()())", where the longest valid parentheses substring is "()()", which has length = 4.
-----------------------------------------------
122:https://oj.leetcode.com/problems/next-permutation/
name:Next Permutation    date:2012-02-25    rate:25.4%
Next Permutation Total Accepted: 15953 Total Submissions: 62744 My Submissions
Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. If such arrangement is not possible, it must rearrange it as the lowest possible order (ie, sorted in ascending order). The replacement must be in-place, do not allocate extra memory. Here are some examples. Inputs are in the left-hand column and its corresponding outputs are in the right-hand column. 1,2,3 → 1,3,2 3,2,1 → 1,2,3 1,1,5 → 1,5,1
-----------------------------------------------
123:https://oj.leetcode.com/problems/substring-with-concatenation-of-all-words/
name:Substring with Concatenation of All Words    date:2012-02-23    rate:18.1%
Substring with Concatenation of All Words Total Accepted: 13065 Total Submissions: 72218 My Submissions
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 concatenation of each word in L exactly once and without any intervening characters. For example, given: S: "barfoothefoobarman" L: ["foo", "bar"] You should return the indices: [0,9]. (order does not matter).
-----------------------------------------------
124:https://oj.leetcode.com/problems/divide-two-integers/
name:Divide Two Integers    date:2012-02-18    rate:16.4%
Divide Two Integers Total Accepted: 17358 Total Submissions: 105735 My Submissions
Divide two integers without using multiplication, division and mod operator.
-----------------------------------------------
125:https://oj.leetcode.com/problems/implement-strstr/
name:Implement strStr()    date:2012-02-18    rate:22.0%
Implement strStr() Total Accepted: 19960 Total Submissions: 90866 My Submissions
Implement strStr(). Returns a pointer to the first occurrence of needle in haystack, or null if needle is not part of haystack.
-----------------------------------------------
126:https://oj.leetcode.com/problems/remove-element/
name:Remove Element    date:2012-02-16    rate:33.4%
Remove Element Total Accepted: 24581 Total Submissions: 73497 My Submissions
Given an array and a value, remove all instances of that value in place and return the new length. The order of elements can be changed. It doesn't matter what you leave beyond the new length.
-----------------------------------------------
127:https://oj.leetcode.com/problems/remove-duplicates-from-sorted-array/
name:Remove Duplicates from Sorted Array    date:2012-02-16    rate:32.5%
Remove Duplicates from Sorted Array Total Accepted: 26492 Total Submissions: 81458 My Submissions
Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length. Do not allocate extra space for another array, you must do this in place with constant memory. For example, Given input array A = [1,1,2], Your function should return length = 2, and A is now [1,2].
-----------------------------------------------
128:https://oj.leetcode.com/problems/reverse-nodes-in-k-group/
name:Reverse Nodes in k-Group    date:2012-02-15    rate:24.9%
Reverse Nodes in k-Group Total Accepted: 14861 Total Submissions: 59659 My Submissions
Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. If the number of nodes is not a multiple of k then left-out nodes in the end should remain as it is. You may not alter the values in the nodes, only nodes itself may be changed. Only constant memory is allowed. For example, Given this linked list: 1->2->3->4->5 For k = 2, you should return: 2->1->4->3->5 For k = 3, you should return: 3->2->1->4->5
-----------------------------------------------
129:https://oj.leetcode.com/problems/swap-nodes-in-pairs/
name:Swap Nodes in Pairs    date:2012-02-14    rate:32.5%
Swap Nodes in Pairs Total Accepted: 22319 Total Submissions: 68615 My Submissions
Given a linked list, swap every two adjacent nodes and return its head. For example, Given 1->2->3->4, you should return the list as 2->1->4->3. Your algorithm should use only constant space. You may not modify the values in the list, only nodes itself can be changed.
-----------------------------------------------
130:https://oj.leetcode.com/problems/merge-k-sorted-lists/
name:Merge k Sorted Lists    date:2012-02-13    rate:21.6%
Merge k Sorted Lists Total Accepted: 18742 Total Submissions: 86569 My Submissions
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.
-----------------------------------------------
131:https://oj.leetcode.com/problems/generate-parentheses/
name:Generate Parentheses    date:2012-02-12    rate:31.5%
Generate Parentheses Total Accepted: 20888 Total Submissions: 66280 My Submissions
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: "((()))", "(()())", "(())()", "()(())", "()()()"
-----------------------------------------------
132:https://oj.leetcode.com/problems/valid-parentheses/
name:Valid Parentheses    date:2012-01-30    rate:28.4%
Valid Parentheses Total Accepted: 19301 Total Submissions: 67949 My Submissions
Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. The brackets must close in the correct order, "()" and "()[]{}" are all valid but "(]" and "([)]" are not.
-----------------------------------------------
133:https://oj.leetcode.com/problems/remove-nth-node-from-end-of-list/
name:Remove Nth Node From End of List    date:2012-01-27    rate:29.9%
Remove Nth Node From End of List Total Accepted: 21764 Total Submissions: 72765 My Submissions
Given a linked list, remove the nth node from the end of list and return its head. For example,  
   Given linked list: 1->2->3->4->5, and n = 2.
 
   After removing the second node from the end, the linked list becomes 1->2->3->5.
 Note: Given n will always be valid. Try to do this in one pass.
-----------------------------------------------
134:https://oj.leetcode.com/problems/letter-combinations-of-a-phone-number/
name:Letter Combinations of a Phone Number    date:2012-01-26    rate:26.3%
Letter Combinations of a Phone Number Total Accepted: 17054 Total Submissions: 64759 My Submissions
Given a digit string, return all possible letter combinations that the number could represent. A mapping of digit to letters (just like on the telephone buttons) is given below.  
Input:Digit string "23"
Output: ["ad", "ae", "af", "bd", "be", "bf", "cd", "ce", "cf"].
 Note: Although the above answer is in lexicographical order, your answer could be in any order you want.
-----------------------------------------------
135:https://oj.leetcode.com/problems/4sum/
name:4Sum    date:2012-01-26    rate:21.5%
4Sum Total Accepted: 14871 Total Submissions: 69009 My Submissions
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 which gives the sum of target. Note: Elements in a quadruplet (a,b,c,d) must be in non-descending order. (ie, a ≤ b ≤ c ≤ d) The solution set must not contain duplicate quadruplets.  
    For example, given array S = {1 0 -1 0 -2 2}, and target = 0.
 
    A solution set is:
    (-1,  0, 0, 1)
    (-2, -1, 1, 2)
    (-2,  0, 0, 2)
-----------------------------------------------
136:https://oj.leetcode.com/problems/3sum-closest/
name:3Sum Closest    date:2012-01-18    rate:27.2%
3Sum Closest Total Accepted: 16727 Total Submissions: 61605 My Submissions
Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would have exactly one solution.  
    For example, given array S = {-1 2 1 -4}, and target = 1.
 
    The sum that is closest to the target is 2. (-1 + 2 + 1 = 2).
-----------------------------------------------
137:https://oj.leetcode.com/problems/3sum/
name:3Sum    date:2012-01-17    rate:16.9%
3Sum Total Accepted: 23348 Total Submissions: 138058 My Submissions
Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero. Note: Elements in a triplet (a,b,c) must be in non-descending order. (ie, a ≤ b ≤ c) The solution set must not contain duplicate triplets.  
    For example, given array S = {-1 0 1 2 -1 -4},
 
    A solution set is:
    (-1, 0, 1)
    (-1, -1, 2)
-----------------------------------------------
138:https://oj.leetcode.com/problems/longest-common-prefix/
name:Longest Common Prefix    date:2012-01-17    rate:27.2%
Longest Common Prefix Total Accepted: 18487 Total Submissions: 67907 My Submissions
Write a function to find the longest common prefix string amongst an array of strings.
-----------------------------------------------
139:https://oj.leetcode.com/problems/roman-to-integer/
name:Roman to Integer    date:2012-01-15    rate:34.0%
Roman to Integer Total Accepted: 15458 Total Submissions: 45519 My Submissions
Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999.
-----------------------------------------------
140:https://oj.leetcode.com/problems/integer-to-roman/
name:Integer to Roman    date:2012-01-15    rate:33.6%
Integer to Roman Total Accepted: 14768 Total Submissions: 43928 My Submissions
Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 to 3999.
-----------------------------------------------
141:https://oj.leetcode.com/problems/container-with-most-water/
name:Container With Most Water    date:2012-01-08    rate:31.3%
Container With Most Water Total Accepted: 17140 Total Submissions: 54708 My Submissions
Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find two lines, which together with x-axis forms a container, such that the container contains the most water. Note: You may not slant the container.
-----------------------------------------------
142:https://oj.leetcode.com/problems/regular-expression-matching/
name:Regular Expression Matching    date:2012-01-08    rate:20.1%
Regular Expression Matching Total Accepted: 17536 Total Submissions: 87343 My Submissions
Implement regular expression matching with support for '.' and '*'.  
'.' Matches any single character.
'*' Matches zero or more of the preceding element.
 
The matching should cover the entire input string (not partial).
 
The function prototype should be:
bool isMatch(const char *s, const char *p)
 
Some examples:
isMatch("aa","a") → false
isMatch("aa","aa") → true
isMatch("aaa","aa") → false
isMatch("aa", "a*") → true
isMatch("aa", ".*") → true
isMatch("ab", ".*") → true
isMatch("aab", "c*a*b") → true
-----------------------------------------------
143:https://oj.leetcode.com/problems/palindrome-number/
name:Palindrome Number    date:2012-01-04    rate:29.0%
Palindrome Number Total Accepted: 21932 Total Submissions: 75516 My Submissions
Determine whether an integer is a palindrome. Do this without extra space. click to show spoilers. Some hints: Could negative integers be palindromes? (ie, -1) If you are thinking of converting the integer to string, note the restriction of using extra space. You could also try reversing an integer. However, if you have solved the problem "Reverse Integer", you know that the reversed integer might overflow. How would you handle such case? There is a more generic way of solving this problem.
-----------------------------------------------
144:https://oj.leetcode.com/problems/string-to-integer-atoi/
name:String to Integer (atoi)    date:2011-12-26    rate:14.7%
String to Integer (atoi) Total Accepted: 17602 Total Submissions: 119825 My Submissions
Implement atoi to convert a string to an integer. Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possible input cases. Notes: It is intended for this problem to be specified vaguely (ie, no given input specs). You are responsible to gather all the input requirements up front. spoilers alert... click to show requirements for atoi. Requirements for atoi: The function first discards as many whitespace characters as necessary until the first non-whitespace character is found. Then, starting from this character, takes an optional initial plus or minus sign followed by as many numerical digits as possible, and interprets them as a numerical value. The string can contain additional characters after those that form the integral number, which are ignored and have no effect on the behavior of this function. If the first sequence of non-whitespace characters in str is not a valid integral number, or if no such sequence exists because either str is empty or it contains only whitespace characters, no conversion is performed. If no valid conversion could be performed, a zero value is returned. If the correct value is out of the range of representable values, INT_MAX (2147483647) or INT_MIN (-2147483648) is returned.
-----------------------------------------------
145:https://oj.leetcode.com/problems/reverse-integer/
name:Reverse Integer    date:2011-12-25    rate:40.3%
Reverse Integer Total Accepted: 31386 Total Submissions: 77866 My Submissions
Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 click to show spoilers. Have you thought about this? Here are some good questions to ask before coding. Bonus points for you if you have already thought through this! If the integer's last digit is 0, what should the output be? ie, cases such as 10, 100. Did you notice that the reversed integer might overflow? Assume the input is a 32-bit integer, then the reverse of 1000000003 overflows. How should you handle such cases? Throw an exception? Good, but what if throwing an exception is not an option? You would then have to re-design the function (ie, add an extra parameter).
-----------------------------------------------
146:https://oj.leetcode.com/problems/zigzag-conversion/
name:ZigZag Conversion    date:2011-12-05    rate:23.8%
ZigZag Conversion Total Accepted: 13193 Total Submissions: 55369 My Submissions
The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)  
P   A   H   N
A P L S I I G
Y   I   R
 And then read line by line: "PAHNAPLSIIGYIR" Write the code that will take a string and make this conversion given a number of rows: string convert(string text, int nRows); convert("PAYPALISHIRING", 3) should return "PAHNAPLSIIGYIR".
-----------------------------------------------
147:https://oj.leetcode.com/problems/longest-palindromic-substring/
name:Longest Palindromic Substring    date:2011-11-11    rate:20.7%
Longest Palindromic Substring Total Accepted: 20074 Total Submissions: 96803 My Submissions
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.
-----------------------------------------------
148:https://oj.leetcode.com/problems/add-two-numbers/
name:Add Two Numbers    date:2011-11-01    rate:23.0%
Add Two Numbers Total Accepted: 23265 Total Submissions: 101068 My Submissions
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 linked list. Input: (2 -> 4 -> 3) + (5 -> 6 -> 4) Output: 7 -> 0 -> 8
-----------------------------------------------
149:https://oj.leetcode.com/problems/longest-substring-without-repeating-characters/
name:Longest Substring Without Repeating Characters    date:2011-05-15    rate:22.3%
Longest Substring Without Repeating Characters Total Accepted: 23633 Total Submissions: 105832 My Submissions
Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3. For "bbbbb" the longest substring is "b", with the length of 1.
-----------------------------------------------
150:https://oj.leetcode.com/problems/median-of-two-sorted-arrays/
name:Median of Two Sorted Arrays    date:2011-03-27    rate:17.5%
Median of Two Sorted Arrays Total Accepted: 21168 Total Submissions: 120913 My Submissions
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 (m+n)).
-----------------------------------------------
151:https://oj.leetcode.com/problems/two-sum/
name:Two Sum    date:2011-03-13    rate:18.5%
Two Sum Total Accepted: 33391 Total Submissions: 180391 My Submissions
Given an array of integers, find two numbers such that they add up to a specific target number. The function twoSum should return indices of the two numbers such that they add up to the target, where index1 must be less than index2. Please note that your returned answers (both index1 and index2) are not zero-based. You may assume that each input would have exactly one solution. Input: numbers={2, 7, 11, 15}, target=9 Output: index1=1, index2=2
-----------------------------------------------
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值