A peak element is an element that is greater than its neighbors. Given an input array where num[i] ≠ num[i+1], find a peak element and return its inde......

Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), prove that at least one duplicate number must exist. ......

Given an array of strings, group anagrams together. For example, given: ["eat", "tea", "tan", "ate", "nat", "bat"], Return: [ ["ate", "eat","tea"], ["......

LeetCode上的相关题目(easy) 26,  27, 35, 48, 88 118, 119, 121, 122, 136, 162, 167, 169 217, 219, 243, 268, 283 303, 349, 350 414, 448, 453, 485, 496 532, 561......

You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise). 这道题看似很复杂，其实就是数组的切换，但是实现起来也并不是非常容易，需要非常小心的操作。 我之前用j......

Given an integer array, you need to find one continuous subarray that if you only sort this subarray in ascending order, then the whole array will be ......

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 ......

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] ]......

Given a list of words and two words word1 and word2, return the shortest distance between these two words in the list. For example, Assume that words ......

Given a word, you need to judge whether the usage of capitals in it is right or not. We define the usage of capitals in a word to be right when one of......

Implement strStr(). Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. 估计有不少人和我一样对strStr()不熟悉。。......

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......

Given m arrays, and each array is sorted in ascending order. Now you can pick up two integers from two different arrays (each array picks one) and cal......

Given an array consisting of n integers, find the contiguous subarray of given length k that has the maximum average value. And you need to output the......

Given an integer array, find three numbers whose product is maximum and output the maximum product. Example 1: Input: [1,2,3] Output: 6 Example 2: Inp......

Given an m * n matrix M initialized with all 0's and several update operations. Operations are represented by a 2D array, and each operation is repres......

We define a harmonious array is an array where the difference between its maximum value and its minimum value is exactly 1. Now, given an integer arra......

Given an integer array with even length, where different numbers in this array represent different kinds of candies. Each number means one candy of th......

In MATLAB, there is a very useful function called 'reshape', which can reshape a matrix into a new one with different size but keep its original data.......

Given an array of 2n integers, your task is to group these integers into n pairs of integer, say (a1, b1), (a2, b2), ..., (an, bn) which makes sum of ......