152. Maximum Product Subarray

2019-02-14
阅读 2 分钟
1.1k
Given an integer array nums, find the contiguous subarray within an array (containing at least one number) which has the largest product.

153. Find Minimum in Rotated Sorted Array

2019-02-14
阅读 2 分钟
1.7k
Suppose an array sorted in ascending order 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]).Find the minimum element.You may assume no duplicate exists in the array.

162. Find Peak Element

2019-02-14
阅读 2 分钟
1.3k
A peak element is an element that is greater than its neighbors.Given an input array nums, where nums[i] ≠ nums[i+1], find a peak element and return its index.The array may contain multiple peaks, in that case return the index to any one of the peaks is fine.You may imagine that nums[-1] = nums[n...

173. Binary Search Tree Iterator

2019-02-14
阅读 2 分钟
1.2k
Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.Calling next() will return the next smallest number in the BST.

94. Binary Tree Inorder Traversal

2019-02-14
阅读 1 分钟
1.7k
Given a binary tree, return the inorder traversal of its nodes' values.

165. Compare Version Numbers

2019-02-14
阅读 2 分钟
1.6k
Compare two version numbers version1 and version2.If version1 > version2 return 1; if version1 < version2 return -1;otherwise return 0.You may assume that the version strings are non-empty and contain only digits and the . character.The . character does not represent a decimal point and is ...

179. Largest Number

2019-02-14
阅读 1 分钟
1.5k
Given a list of non negative integers, arrange them such that they form the largest number.

199. Binary Tree Right Side View

2019-02-14
阅读 2 分钟
1.2k
Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom.

93. Restore IP Addresses

2019-02-13
阅读 2 分钟
1.5k
Given a string containing only digits, restore it by returning all possible valid IP address combinations.

92. Reverse Linked List II

2019-02-13
阅读 2 分钟
1.8k
Reverse a linked list from position m to n. Do it in one-pass.Note: 1 ≤ m ≤ n ≤ length of list.

55. Jump Game

2019-02-13
阅读 1 分钟
1.3k
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.

77. Combinations

2019-02-13
阅读 1 分钟
1.4k
Given two integers n and k, return all possible combinations of k numbers out of 1 ... n.

78. Subsets

2019-02-13
阅读 2 分钟
1.3k
Given a set of distinct integers, nums, return all possible subsets (the power set).

74. Search a 2D Matrix

2019-02-12
阅读 2 分钟
1.1k
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.Example 1:

73. Set Matrix Zeroes

2019-02-12
阅读 2 分钟
960
Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in-place.

60. Permutation Sequence

2019-02-12
阅读 2 分钟
1.3k
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 for n = 3:

81. Search in Rotated Sorted Array II

2019-02-12
阅读 2 分钟
1.6k
Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.(i.e., [0,0,1,2,2,5,6] might become [2,5,6,0,0,1,2]).You are given a target value to search. If found in the array return true, otherwise return false.Example 1:

75. Sort Colors

2019-02-12
阅读 3 分钟
1.3k
Given an array with n objects colored red, white or blue, sort them in-place 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 suppo...

79. Word Search

2019-02-12
阅读 2 分钟
1k
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.

90. Subsets II

2019-02-12
阅读 2 分钟
1k
Given a collection of integers that might contain duplicates, nums, return all possible subsets (the power set).Note: The solution set must not contain duplicate subsets.Example:

80. Remove Duplicates from Sorted Array II

2019-02-12
阅读 2 分钟
992
Given a sorted array nums, remove the duplicates in-place such that duplicates appeared at most twice and return the new length.Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory.

82. Remove Duplicates from Sorted List II

2019-02-12
阅读 2 分钟
1.3k
Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.

86. Partition List

2019-02-12
阅读 2 分钟
1.2k
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.

64. Minimum Path Sum

2019-02-12
阅读 1 分钟
1.3k
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.

71. Simplify Path

2019-02-12
阅读 2 分钟
1k
Given an absolute path for a file (Unix-style), simplify it. Or in other words, convert it to the canonical path.In a UNIX-style file system, a period . refers to the current directory. Furthermore, a double period .. moves the directory up a level. For more information, see: Absolute path vs rel...

91. Decode Ways

2019-02-12
阅读 3 分钟
1.3k
A message containing letters from A-Z is being encoded to numbers using the following mapping:

61. Rotate List

2019-02-11
阅读 2 分钟
1.3k
Given a linked list, rotate the list to the right by k places, where k is non-negative.

63. Unique Paths II

2019-02-11
阅读 2 分钟
1.2k
A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).

62. Unique Paths

2019-02-11
阅读 2 分钟
1.2k
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...

56. Merge Intervals

2019-02-11
阅读 2 分钟
1.2k
Given a collection of intervals, merge all overlapping intervals. Example 1: {代码...} Example 2: {代码...} 难度:medium 题目:给定间隔点集合,合并所有重复的间隔。 思路:先排序然后合并。 Runtime: 57 ms, faster than 21.60% of Java online submissions for Merge Intervals.Memory Usage: 35 MB, less th...