array
-
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…
-
LeetCode – 532. K-diff Pairs in an Array
Given an array of integers and an integer k, you need to find the number of unique k-diff pairs in t…
-
LeetCode – 496. Next Greater Element I
You are given two arrays (without duplicates) nums1 and nums2 where nums1’s elements are subset of n…
-
LeetCode – 485. Max Consecutive Ones
Given a binary array, find the maximum number of consecutive 1s in this array. Example 1: Input: [1,…
-
LeetCode – 453. Minimum Moves to Equal Array Elements
Given a non-empty integer array of size n, find the minimum number of moves required to make all arr…
-
LeetCode – 448. Find All Numbers Disappeared in an Array
Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and ot…
-
LeetCode – 414. Third Maximum Number
Given a non-empty array of integers, return the third maximum number in this array. If it does not e…
-
LeetCode – 350. Intersection of Two Arrays II
Given two arrays, write a function to compute their intersection. Example:Given nums1 = [1, 2, 2, 1]…
-
LeetCode – 349. Intersection of Two Arrays
Given two arrays, write a function to compute their intersection. Example:Given nums1 = [1, 2, 2, 1]…
-
LeetCode – 303. Range Sum Query – Immutable
Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive…
-
LeetCode – 283. Move Zeroes
Given an array nums, write a function to move all 0‘s to the end of it while maintaining the r…