
LeetCode – 28. Implement strStr()
Implement strStr(). Returns the index of the first occurrence of needle in haystack, or -1 if needle…

LeetCode – 605. Can Place Flowers
Suppose you have a long flowerbed in which some of the plots are planted and some are not. However, …

LeetCode – 624. Maximum Distance in Arrays
Given m arrays, and each array is sorted in ascending order. Now you can pick up two integers from t…

643. Maximum Average Subarray I
Given an array consisting of n integers, find the contiguous subarray of given length k that has the…

LeetCode – 628. Maximum Product of Three Numbers
Given an integer array, find three numbers whose product is maximum and output the maximum product. …

LeetCode – 598. Range Addition II
Given an m * n matrix M initialized with all 0‘s and several update operations. Operations are…

LeetCode – 594. Longest Harmonious Subsequence
We define a harmonious array is an array where the difference between its maximum value and its mini…

LeetCode – 575. Distribute Candies
Given an integer array with even length, where different numbers in this array represent different k…

LeetCode – 566. Reshape the Matrix
In MATLAB, there is a very useful function called ‘reshape’, which can reshape a matrix …

LeetCode – 561. Array Partition I
Given an array of 2n integers, your task is to group these integers into n pairs of integer, say (a1…