[LeetCode] 448. Find All Numbers Disappeared in an Array

2019-01-14
阅读 1 分钟
1.5k
Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.

[LeetCode] 442. Find All Duplicates in an Array

2019-01-14
阅读 1 分钟
1.7k
Given an array of integers, 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.

[LeetCode] 84. Largest Rectangle in Histogram

2019-01-14
阅读 2 分钟
1.6k
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.

[LeetCode] 605. Can Place Flowers

2018-12-31
阅读 2 分钟
1.7k
Suppose you have a long flowerbed in which some of the plots are planted and some are not. However, flowers cannot be planted in adjacent plots - they would compete for water and both would die.

[LeetCode] 867. Transpose Matrix

2018-12-31
阅读 1 分钟
1.8k
The transpose of a matrix is the matrix flipped over it's main diagonal, switching the row and column indices of the matrix.

[LeetCode] 475. Heaters

2018-12-31
阅读 2 分钟
1.5k
Winter is coming! Your first job during the contest is to design a standard heater with fixed warm radius to warm all the houses.

[LeetCode] 905. Sort Array By Parity

2018-12-31
阅读 1 分钟
1.6k
Given an array A of non-negative integers, return an array consisting of all the even elements of A, followed by all the odd elements of A.

[LeetCode] 51. N-Queens

2018-12-30
阅读 2 分钟
2.3k
The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other.

[LeetCode] 702. Search in a Sorted Array of Unknown Size

2018-12-14
阅读 2 分钟
4.6k
Given an integer array sorted in ascending order, write a function to search target in nums. If target exists, then return its index, otherwise return -1. However, the array size is unknown to you. You may only access the array using an ArrayReader interface, where ArrayReader.get(k) returns the ...

[LeetCode] 280. Wiggle Sort

2018-12-14
阅读 1 分钟
1.7k
Given an unsorted array nums, reorder it in-place such that nums[0] <= nums[1] >= nums[2] <= nums[3]....

[LeetCode] 243. Shortest Word Distance

2018-12-14
阅读 1 分钟
1.6k
Given a list of words and two words word1 and word2, return the shortest distance between these two words in the list.

[LeetCode] 487. Max Consecutive Ones II

2018-12-14
阅读 1 分钟
1.8k
Given a binary array, find the maximum number of consecutive 1s in this array if you can flip at most one 0.

[LeetCode] 48. Rotate Image

2018-12-13
阅读 2 分钟
1.6k
You have to rotate the image in-place, which means you have to modify the input 2D matrix directly. DO NOT allocate another 2D matrix and do the rotation.

[LeetCode] 41. First Missing Positive

2018-12-06
阅读 1 分钟
1.5k
Given an unsorted integer array, find the smallest missing positive integer.

[LeetCode] 209. Minimum Size Subarray Sum (Easy version LC 862)

2018-11-26
阅读 1 分钟
1.6k
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.

[LeetCode] 548. Split Array with Equal Sum

2018-11-26
阅读 2 分钟
3.4k
Given an array with n integers, you need to find if there are triplets (i, j, k) which satisfies following conditions:

[LeetCode] 852. Peak Index in a Mountain Array

2018-11-25
阅读 2 分钟
1.6k
A.length >= 3There exists some 0 < i < A.length - 1 such that A[0] < A[1] < ... A[i-1] < A[i] > A[i+1] > ... > A[A.length - 1]Given an array that is definitely a mountain, return any i such that A[0] < A[1] < ... A[i-1] < A[i] > A[i+1] > ... > A[A.leng...

[LeetCode] 724. Find Pivot Index

2018-11-24
阅读 2 分钟
1.1k
Given an array of integers nums, write a method that returns the "pivot" index of this array.

[LeetCode] 158. Read N Characters Given Read4 II - Call multiple

2018-11-23
阅读 2 分钟
2.4k
The API: int read4(char *buf) reads 4 characters at a time from a file.

[LeetCode] 526. Beautiful Arrangement

2018-11-18
阅读 2 分钟
1.8k
Suppose you have N integers from 1 to N. We define a beautiful arrangement as an array that is constructed by these N numbers successfully if one of the following is true for the ith position (1 <= i <= N) in this array:

[LeetCode] 628. Maximum Product of Three Numbers

2018-11-08
阅读 2 分钟
1.5k
Given an integer array, find three numbers whose product is maximum and output the maximum product.

[LeetCode] 448. Find All Numbers Disappeared in an Array

2018-11-08
阅读 1 分钟
1k
Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.

[LeetCode] 849. Maximize Distance to Closest Person

2018-10-31
阅读 2 分钟
2.1k
In a row of seats, 1 represents a person sitting in that seat, and 0 represents that the seat is empty.

[LeetCode] 674. Longest Continuous Increasing Subsequence

2018-10-09
阅读 2 分钟
1.7k
Given an unsorted array of integers, find the length of longest continuous increasing subsequence (subarray).

[LeetCode] 253. Meeting Rooms II

2018-09-26
阅读 2 分钟
3.7k
Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],...] (si < ei), find the minimum number of conference rooms required.

[LeetCode] 896. Monotonic Array

2018-09-25
阅读 2 分钟
2.3k
An array is monotonic if it is either monotone increasing or monotone decreasing.

[LeetCode] 611. Valid Triangle Number

2018-09-24
阅读 1 分钟
2.3k
Given an array consists of non-negative integers, your task is to count the number of triplets chosen from the array that can make triangles if we take them as side lengths of a triangle.Example 1:Input: [2,2,3,4]Output: 3Explanation:Valid combinations are: 2,3,4 (using the first 2)2,3,4 (using t...

[LeetCode] 277. Find the Celebrity

2018-09-19
阅读 3 分钟
2.7k
Suppose you are at a party with n people (labeled from 0 to n - 1) and among them, there may exist one celebrity. The definition of a celebrity is that all the other n - 1 people know him/her but he/she does not know any of them.

[LeetCode] Binary Search [Beat 100%]

2018-09-18
阅读 1 分钟
1.3k
Given a sorted (in ascending order) integer array nums of n elements and a target value, write a function to search target in nums. If target exists, then return its index, otherwise return -1.

[LeetCode] String Compression

2018-08-21
阅读 2 分钟
2.3k
The length after compression must always be smaller than or equal to the original array.