Episode 7 — DSA with JavaScript / 7.3 — Arrays
7.3 — Exercise Questions: Arrays
Easy
E1. Find the Maximum and Minimum
Given an array, find both the maximum and minimum in a single pass.
Solution (JS)
function minMax(arr) {
let min = arr[0], max = arr[0];
for (let i = 1; i < arr.length; i++) {
if (arr[i] < min) min = arr[i];
if (arr[i] > max) max = arr[i];
}
return { min, max };
}
Solution (C++)
pair<int,int> minMax(const vector<int>& arr) {
int mn = arr[0], mx = arr[0];
for (int x : arr) { mn = min(mn, x); mx = max(mx, x); }
return {mn, mx};
}
E2. Reverse an Array
Reverse the array in-place.
Solution (JS)
function reverseArr(arr) {
let l = 0, r = arr.length - 1;
while (l < r) { [arr[l], arr[r]] = [arr[r], arr[l]]; l++; r--; }
return arr;
}
E3. Check if Array is Sorted
Solution (JS)
function isSorted(arr) {
for (let i = 1; i < arr.length; i++) {
if (arr[i] < arr[i-1]) return false;
}
return true;
}
E4. Move Zeros to End
Move all zeros to the end while maintaining order of non-zero elements.
Solution (JS)
function moveZeros(arr) {
let writeIdx = 0;
for (let i = 0; i < arr.length; i++) {
if (arr[i] !== 0) {
[arr[writeIdx], arr[i]] = [arr[i], arr[writeIdx]];
writeIdx++;
}
}
return arr;
}
// [0, 1, 0, 3, 12] → [1, 3, 12, 0, 0]
E5. Find Missing Number (1 to N)
Solution (JS)
function missingNumber(arr, n) {
return n * (n + 1) / 2 - arr.reduce((a, b) => a + b, 0);
}
Medium
E6. Two Sum
Given an array and target, return indices of two numbers that sum to target.
Solution (JS)
function twoSum(arr, target) {
const map = new Map();
for (let i = 0; i < arr.length; i++) {
const complement = target - arr[i];
if (map.has(complement)) return [map.get(complement), i];
map.set(arr[i], i);
}
return null;
}
E7. Maximum Subarray Sum (Kadane's)
Solution (JS)
function maxSubSum(arr) {
let curr = arr[0], best = arr[0];
for (let i = 1; i < arr.length; i++) {
curr = Math.max(arr[i], curr + arr[i]);
best = Math.max(best, curr);
}
return best;
}
E8. Rotate Array by K
Solution (JS)
function rotate(arr, k) {
k %= arr.length;
const rev = (l, r) => { while (l < r) { [arr[l], arr[r]] = [arr[r], arr[l]]; l++; r--; } };
rev(0, arr.length - 1);
rev(0, k - 1);
rev(k, arr.length - 1);
return arr;
}
E9. Dutch National Flag (Sort 0s, 1s, 2s)
Solution (JS)
function sortColors(arr) {
let lo = 0, mid = 0, hi = arr.length - 1;
while (mid <= hi) {
if (arr[mid] === 0) { [arr[lo], arr[mid]] = [arr[mid], arr[lo]]; lo++; mid++; }
else if (arr[mid] === 1) mid++;
else { [arr[mid], arr[hi]] = [arr[hi], arr[mid]]; hi--; }
}
return arr;
}
E10. Stock Buy and Sell (Max Profit)
Solution (JS)
function maxProfit(prices) {
let minPrice = prices[0], maxProfit = 0;
for (let i = 1; i < prices.length; i++) {
minPrice = Math.min(minPrice, prices[i]);
maxProfit = Math.max(maxProfit, prices[i] - minPrice);
}
return maxProfit;
}
Hard
E11. Trapping Rain Water
Solution (JS)
function trap(height) {
let l = 0, r = height.length - 1, lMax = 0, rMax = 0, water = 0;
while (l < r) {
if (height[l] < height[r]) {
lMax = Math.max(lMax, height[l]);
water += lMax - height[l];
l++;
} else {
rMax = Math.max(rMax, height[r]);
water += rMax - height[r];
r--;
}
}
return water;
}
E12. Product of Array Except Self
Solution (JS)
function productExceptSelf(nums) {
const n = nums.length, res = new Array(n).fill(1);
let left = 1;
for (let i = 0; i < n; i++) { res[i] = left; left *= nums[i]; }
let right = 1;
for (let i = n-1; i >= 0; i--) { res[i] *= right; right *= nums[i]; }
return res;
}
E13. Longest Consecutive Sequence
Solution (JS)
function longestConsecutive(nums) {
const set = new Set(nums);
let longest = 0;
for (const num of set) {
if (!set.has(num - 1)) {
let len = 1, curr = num;
while (set.has(curr + 1)) { curr++; len++; }
longest = Math.max(longest, len);
}
}
return longest;
}
Additional exercise bank
EX-014
- Problem: Array exercise #14.
- Difficulty: Easy
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-015
- Problem: Array exercise #15.
- Difficulty: Easy
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-016
- Problem: Array exercise #16.
- Difficulty: Easy
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-017
- Problem: Array exercise #17.
- Difficulty: Easy
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-018
- Problem: Array exercise #18.
- Difficulty: Easy
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-019
- Problem: Array exercise #19.
- Difficulty: Easy
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-020
- Problem: Array exercise #20.
- Difficulty: Easy
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-021
- Problem: Array exercise #21.
- Difficulty: Easy
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-022
- Problem: Array exercise #22.
- Difficulty: Easy
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-023
- Problem: Array exercise #23.
- Difficulty: Easy
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-024
- Problem: Array exercise #24.
- Difficulty: Easy
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-025
- Problem: Array exercise #25.
- Difficulty: Easy
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-026
- Problem: Array exercise #26.
- Difficulty: Easy
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-027
- Problem: Array exercise #27.
- Difficulty: Easy
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-028
- Problem: Array exercise #28.
- Difficulty: Easy
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-029
- Problem: Array exercise #29.
- Difficulty: Easy
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-030
- Problem: Array exercise #30.
- Difficulty: Easy
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-031
- Problem: Array exercise #31.
- Difficulty: Easy
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-032
- Problem: Array exercise #32.
- Difficulty: Easy
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-033
- Problem: Array exercise #33.
- Difficulty: Easy
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-034
- Problem: Array exercise #34.
- Difficulty: Easy
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-035
- Problem: Array exercise #35.
- Difficulty: Easy
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-036
- Problem: Array exercise #36.
- Difficulty: Easy
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-037
- Problem: Array exercise #37.
- Difficulty: Easy
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-038
- Problem: Array exercise #38.
- Difficulty: Easy
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-039
- Problem: Array exercise #39.
- Difficulty: Easy
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-040
- Problem: Array exercise #40.
- Difficulty: Easy
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-041
- Problem: Array exercise #41.
- Difficulty: Easy
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-042
- Problem: Array exercise #42.
- Difficulty: Easy
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-043
- Problem: Array exercise #43.
- Difficulty: Easy
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-044
- Problem: Array exercise #44.
- Difficulty: Easy
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-045
- Problem: Array exercise #45.
- Difficulty: Easy
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-046
- Problem: Array exercise #46.
- Difficulty: Easy
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-047
- Problem: Array exercise #47.
- Difficulty: Easy
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-048
- Problem: Array exercise #48.
- Difficulty: Easy
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-049
- Problem: Array exercise #49.
- Difficulty: Easy
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-050
- Problem: Array exercise #50.
- Difficulty: Medium
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-051
- Problem: Array exercise #51.
- Difficulty: Medium
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-052
- Problem: Array exercise #52.
- Difficulty: Medium
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-053
- Problem: Array exercise #53.
- Difficulty: Medium
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-054
- Problem: Array exercise #54.
- Difficulty: Medium
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-055
- Problem: Array exercise #55.
- Difficulty: Medium
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-056
- Problem: Array exercise #56.
- Difficulty: Medium
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-057
- Problem: Array exercise #57.
- Difficulty: Medium
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-058
- Problem: Array exercise #58.
- Difficulty: Medium
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-059
- Problem: Array exercise #59.
- Difficulty: Medium
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-060
- Problem: Array exercise #60.
- Difficulty: Medium
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-061
- Problem: Array exercise #61.
- Difficulty: Medium
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-062
- Problem: Array exercise #62.
- Difficulty: Medium
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-063
- Problem: Array exercise #63.
- Difficulty: Medium
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-064
- Problem: Array exercise #64.
- Difficulty: Medium
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-065
- Problem: Array exercise #65.
- Difficulty: Medium
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-066
- Problem: Array exercise #66.
- Difficulty: Medium
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-067
- Problem: Array exercise #67.
- Difficulty: Medium
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-068
- Problem: Array exercise #68.
- Difficulty: Medium
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-069
- Problem: Array exercise #69.
- Difficulty: Medium
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-070
- Problem: Array exercise #70.
- Difficulty: Medium
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-071
- Problem: Array exercise #71.
- Difficulty: Medium
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-072
- Problem: Array exercise #72.
- Difficulty: Medium
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-073
- Problem: Array exercise #73.
- Difficulty: Medium
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-074
- Problem: Array exercise #74.
- Difficulty: Medium
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-075
- Problem: Array exercise #75.
- Difficulty: Medium
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-076
- Problem: Array exercise #76.
- Difficulty: Medium
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-077
- Problem: Array exercise #77.
- Difficulty: Medium
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-078
- Problem: Array exercise #78.
- Difficulty: Medium
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-079
- Problem: Array exercise #79.
- Difficulty: Medium
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-080
- Problem: Array exercise #80.
- Difficulty: Medium
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-081
- Problem: Array exercise #81.
- Difficulty: Medium
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-082
- Problem: Array exercise #82.
- Difficulty: Medium
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-083
- Problem: Array exercise #83.
- Difficulty: Medium
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-084
- Problem: Array exercise #84.
- Difficulty: Medium
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-085
- Problem: Array exercise #85.
- Difficulty: Medium
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-086
- Problem: Array exercise #86.
- Difficulty: Medium
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-087
- Problem: Array exercise #87.
- Difficulty: Medium
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-088
- Problem: Array exercise #88.
- Difficulty: Medium
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-089
- Problem: Array exercise #89.
- Difficulty: Medium
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-090
- Problem: Array exercise #90.
- Difficulty: Medium
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-091
- Problem: Array exercise #91.
- Difficulty: Medium
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-092
- Problem: Array exercise #92.
- Difficulty: Medium
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-093
- Problem: Array exercise #93.
- Difficulty: Medium
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-094
- Problem: Array exercise #94.
- Difficulty: Medium
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-095
- Problem: Array exercise #95.
- Difficulty: Medium
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-096
- Problem: Array exercise #96.
- Difficulty: Medium
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-097
- Problem: Array exercise #97.
- Difficulty: Medium
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-098
- Problem: Array exercise #98.
- Difficulty: Medium
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-099
- Problem: Array exercise #99.
- Difficulty: Medium
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-100
- Problem: Array exercise #100.
- Difficulty: Medium
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-101
- Problem: Array exercise #101.
- Difficulty: Medium
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-102
- Problem: Array exercise #102.
- Difficulty: Medium
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-103
- Problem: Array exercise #103.
- Difficulty: Medium
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-104
- Problem: Array exercise #104.
- Difficulty: Medium
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-105
- Problem: Array exercise #105.
- Difficulty: Medium
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-106
- Problem: Array exercise #106.
- Difficulty: Medium
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-107
- Problem: Array exercise #107.
- Difficulty: Medium
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-108
- Problem: Array exercise #108.
- Difficulty: Medium
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-109
- Problem: Array exercise #109.
- Difficulty: Medium
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-110
- Problem: Array exercise #110.
- Difficulty: Hard
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-111
- Problem: Array exercise #111.
- Difficulty: Hard
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-112
- Problem: Array exercise #112.
- Difficulty: Hard
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-113
- Problem: Array exercise #113.
- Difficulty: Hard
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-114
- Problem: Array exercise #114.
- Difficulty: Hard
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-115
- Problem: Array exercise #115.
- Difficulty: Hard
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-116
- Problem: Array exercise #116.
- Difficulty: Hard
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-117
- Problem: Array exercise #117.
- Difficulty: Hard
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-118
- Problem: Array exercise #118.
- Difficulty: Hard
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-119
- Problem: Array exercise #119.
- Difficulty: Hard
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-120
- Problem: Array exercise #120.
- Difficulty: Hard
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-121
- Problem: Array exercise #121.
- Difficulty: Hard
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-122
- Problem: Array exercise #122.
- Difficulty: Hard
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-123
- Problem: Array exercise #123.
- Difficulty: Hard
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-124
- Problem: Array exercise #124.
- Difficulty: Hard
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-125
- Problem: Array exercise #125.
- Difficulty: Hard
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-126
- Problem: Array exercise #126.
- Difficulty: Hard
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-127
- Problem: Array exercise #127.
- Difficulty: Hard
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-128
- Problem: Array exercise #128.
- Difficulty: Hard
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-129
- Problem: Array exercise #129.
- Difficulty: Hard
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-130
- Problem: Array exercise #130.
- Difficulty: Hard
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-131
- Problem: Array exercise #131.
- Difficulty: Hard
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-132
- Problem: Array exercise #132.
- Difficulty: Hard
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-133
- Problem: Array exercise #133.
- Difficulty: Hard
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-134
- Problem: Array exercise #134.
- Difficulty: Hard
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-135
- Problem: Array exercise #135.
- Difficulty: Hard
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-136
- Problem: Array exercise #136.
- Difficulty: Hard
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-137
- Problem: Array exercise #137.
- Difficulty: Hard
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-138
- Problem: Array exercise #138.
- Difficulty: Hard
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-139
- Problem: Array exercise #139.
- Difficulty: Hard
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-140
- Problem: Array exercise #140.
- Difficulty: Hard
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-141
- Problem: Array exercise #141.
- Difficulty: Hard
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-142
- Problem: Array exercise #142.
- Difficulty: Hard
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-143
- Problem: Array exercise #143.
- Difficulty: Hard
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-144
- Problem: Array exercise #144.
- Difficulty: Hard
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-145
- Problem: Array exercise #145.
- Difficulty: Hard
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-146
- Problem: Array exercise #146.
- Difficulty: Hard
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-147
- Problem: Array exercise #147.
- Difficulty: Hard
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-148
- Problem: Array exercise #148.
- Difficulty: Hard
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-149
- Problem: Array exercise #149.
- Difficulty: Hard
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-150
- Problem: Array exercise #150.
- Difficulty: Hard
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-151
- Problem: Array exercise #151.
- Difficulty: Hard
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-152
- Problem: Array exercise #152.
- Difficulty: Hard
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-153
- Problem: Array exercise #153.
- Difficulty: Hard
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-154
- Problem: Array exercise #154.
- Difficulty: Hard
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-155
- Problem: Array exercise #155.
- Difficulty: Hard
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-156
- Problem: Array exercise #156.
- Difficulty: Hard
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-157
- Problem: Array exercise #157.
- Difficulty: Hard
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-158
- Problem: Array exercise #158.
- Difficulty: Hard
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-159
- Problem: Array exercise #159.
- Difficulty: Hard
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-160
- Problem: Array exercise #160.
- Difficulty: Hard
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-161
- Problem: Array exercise #161.
- Difficulty: Hard
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-162
- Problem: Array exercise #162.
- Difficulty: Hard
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.
EX-163
- Problem: Array exercise #163.
- Difficulty: Hard
- Key techniques: Two pointers, prefix sum, sliding window, hash map.
- Implementation: Write in both JavaScript and C++.
- Complexity analysis: State time and space for your solution.