26. Remove Duplicates from Sorted Array

2019-02-02
阅读 2 分钟
984
Given a sorted array nums, remove the duplicates in-place such that each element appear only once and return the new length.

35. Search Insert Position

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

21. Merge Two Sorted Lists

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

20. Valid Parentheses

2019-02-02
阅读 2 分钟
1.1k
Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.An input string is valid if:Open brackets must be closed by the same type of brackets.Open brackets must be closed in the correct order.Note that an empty string is also considere...

14. Longest Common Prefix

2019-02-02
阅读 2 分钟
1.2k
Write a function to find the longest common prefix string amongst an array of strings.

13. Roman to Integer

2019-02-02
阅读 3 分钟
1.2k
Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M.

41. First Missing Positive

2019-02-01
阅读 2 分钟
1k
Given an unsorted integer array, find the smallest missing positive integer.

7. Reverse Integer

2019-02-01
阅读 1 分钟
1.1k
Given a 32-bit signed integer, reverse digits of an integer. Example 1:Input: 123Output: 321 Example 2:Input: -123Output: -321 Example 3:Input: 120Output: 21 Note:Assume we are dealing with an environment which could only store integers within the 32-bit signed integer range: [−231, 231 − 1]. For...

1. Two Sum

2019-01-31
阅读 2 分钟
999
Given an array of integers, return indices of the two numbers such that they add up to a specific target.

15. 3Sum

2019-01-29
阅读 2 分钟
1.6k
Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.

12. Integer to Roman

2019-01-29
阅读 3 分钟
1.2k
Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M.

11. Container With Most Water

2019-01-29
阅读 2 分钟
1.4k
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 w...

6. ZigZag Conversion

2019-01-29
阅读 2 分钟
1.3k
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)

337. House Robber III

2019-01-29
阅读 2 分钟
1.3k
The thief has found himself a new place for his thievery again. There is only one entrance to this area, called the "root." Besides the root, each house has one and only one parent house. After a tour, the smart thief realized that "all houses in this place forms a binary tree". It will automatic...

213. House Robber II

2019-01-29
阅读 3 分钟
1.4k
You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed. All houses at this place are arranged in a circle. That means the first house is the neighbor of the last one. Meanwhile, adjacent houses have security system connected and it wi...

198. House Robber

2019-01-29
阅读 2 分钟
1.5k
You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent houses have security system connected and it will automatically contact the police if two adjacent hou...

211. Add and Search Word - Data structure design

2019-01-29
阅读 3 分钟
1.3k
Design a data structure that supports the following two operations:void addWord(word)bool search(word)search(word) can search a literal word or a regular expression string containing only letters a-z or .. A . means it can represent any one letter.

983. Minimum Cost For Tickets

2019-01-28
阅读 3 分钟
2.9k
In a country popular for train travel, you have planned some train travelling one year in advance. The days of the year that you will travel is given as an array days. Each day is an integer from 1 to 365.

959. Regions Cut By Slashes

2019-01-28
阅读 3 分钟
2.4k
In a N x N grid composed of 1 x 1 squares, each 1 x 1 square consists of a /, , or blank space. These characters divide the square into contiguous regions.

513. Find Bottom Left Tree Value

2019-01-28
阅读 2 分钟
1.2k
Given a binary tree, find the leftmost value in the last row of the tree.

542. 01 Matrix

2019-01-28
阅读 2 分钟
1.2k
Given a matrix consists of 0 and 1, find the distance of the nearest 0 for each cell.

210. Course Schedule II

2019-01-27
阅读 3 分钟
1.1k
There are a total of n courses you have to take, labeled from 0 to n-1.

207. Course Schedule

2019-01-27
阅读 4 分钟
1.4k
There are a total of n courses you have to take, labeled from 0 to n-1.

137. Single Number II

2019-01-26
阅读 1 分钟
1.3k
Given a non-empty array of integers, every element appears three times except for one, which appears exactly once. Find that single one.

260. Single Number III

2019-01-26
阅读 2 分钟
945
Given an array of numbers nums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements that appear only once.

187. Repeated DNA Sequences

2019-01-26
阅读 1 分钟
1.2k
All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACGAATTCCG". When studying DNA, it is sometimes useful to identify repeated sequences within the DNA.

208. Implement Trie (Prefix Tree)

2019-01-26
阅读 3 分钟
1.8k
Note:You may assume that all inputs are consist of lowercase letters a-z.All inputs are guaranteed to be non-empty strings.

200. Number of Islands

2019-01-25
阅读 2 分钟
1.2k
Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume all four edges of the grid are all surrounded by water.

209. Minimum Size Subarray Sum

2019-01-25
阅读 2 分钟
1.2k
Given an array of n positive integers and a positive integer s, find the minimal length of a contiguous subarray of which the sum ≥ s. If there isn't one, return 0 instead.

201. Bitwise AND of Numbers Range

2019-01-25
阅读 1 分钟
958
Given a range [m, n] where 0 <= m <= n <= 2147483647, return the bitwise AND of all numbers in this range, inclusive.