Swap two elements

Easy
5 views 23 Jan 2026
Task: swap a[i] and a[j] in an int array....

Copy array manually

Easy
5 views 23 Jan 2026
Task: create and return a new array copy without using Arrays.copyOf....

Find first occurrence

Easy
4 views 23 Jan 2026
Task: return first index of target in array, else -1....

Count occurrences

Easy
4 views 23 Jan 2026
Task: return how many times target appears in array....

Find minimum value

Easy
5 views 23 Jan 2026
Task: return minimum value from non-empty array....

Reverse a subrange

Medium
6 views 23 Jan 2026
Task: reverse elements between l and r inclusive....

Remove element (new length)

Medium
5 views 23 Jan 2026
Task: remove all occurrences of val in-place and return new length (order can change)....

Merge two arrays alternately

Medium
5 views 23 Jan 2026
Task: merge a and b alternately into a new array. Extra tail should be appended at end....

Prefix sum array

Medium
27 views 23 Jan 2026
Task: return prefix sums where pref[i] = sum of a[0..i]....

Find majority element (Boyer-Moore)

Medium
5 views 23 Jan 2026
Task: assume there is a majority element (> n/2). Return it using O(1) space....

Find intersection of two arrays (unique)

Hard
3 views 23 Jan 2026
Task: return unique intersection of a and b....

Minimum window size for sum >= target

Hard
4 views 23 Jan 2026
Task: given positive integers, return min length subarray with sum >= target. If not found return 0....

Rearrange array by sign (stable)

Hard
5 views 23 Jan 2026
Task: place negative numbers first then non-negative, keeping relative order inside each group....

Count inversions (merge sort)

Hard
5 views 23 Jan 2026
Task: return number of inversions in array using merge sort....

Product of array except self

Hard
8 views 23 Jan 2026
Task: return array where res[i] = product of all elements except a[i] (no division)....