🔢 Arrays & Strings Problems

Master array manipulation, two pointers, sliding window, and string algorithms

Given an array of integers and a target, return indices of two numbers that add up to target.
Input: nums = [2,7,11,15], target = 9 → Output: [0,1]

java

Find all unique triplets that sum to zero.
Input: [-1,0,1,2,-1,-4] → Output: [[-1,-1,2],[-1,0,1]]

java

Find the length of the longest substring without repeating characters.
Input: "abcabcbb" → Output: 3 ("abc")

java

Find two lines that together with the x-axis form a container with most water.

java

Find the contiguous subarray with the largest sum.
Input: [-2,1,-3,4,-1,2,1,-5,4] → Output: 6 ([4,-1,2,1])

java

Merge all overlapping intervals.
Input: [[1,3],[2,6],[8,10],[15,18]] → Output: [[1,6],[8,10],[15,18]]

java

Return an array where each element is the product of all elements except itself. No division allowed.
Input: [1,2,3,4] → Output: [24,12,8,6]

java

Given elevation map, compute how much water it can trap after raining.
Input: [0,1,0,2,1,0,1,3,2,1,2,1] → Output: 6

java

Find the minimum window in s which contains all characters of t.
Input: s = "ADOBECODEBANC", t = "ABC" → Output: "BANC"

java

Arrays & Strings Patterns