Reverse an array in-place

Easy
4 views 23 Jan 2026
Task: reverse the given int array without using another array. Try using two pointers (start/end) and swap....

Count even numbers

Easy
4 views 23 Jan 2026
Task: return how many values are even in the given int array. Keep it simple with one loop....

Check array sorted (non-decreasing)

Easy
5 views 23 Jan 2026
Task: return true if the array is sorted in non-decreasing order. Compare adjacent elements....

Find maximum element

Easy
4 views 23 Jan 2026
Task: return the maximum value from a non-empty array....

Sum of array elements

Easy
5 views 23 Jan 2026
Task: return sum of all elements in the array....

Move zeros to end (stable)

Medium
10 views 23 Jan 2026
Task: move all zeros to the end while keeping the relative order of non-zero elements....

Rotate right by k

Medium
5 views 23 Jan 2026
Task: rotate the array to the right by k steps without extra array. Use reverse trick....

Second largest distinct

Medium
6 views 23 Jan 2026
Task: return the second largest distinct value. If it does not exist, return Integer.MIN_VALUE....

Find missing number 1..n

Medium
6 views 23 Jan 2026
Task: array has n-1 numbers from 1..n without duplicates. Return the missing number....

Two sum in sorted array

Medium
5 views 23 Jan 2026
Task: array is sorted. Return indices of two numbers that sum to target, else [-1,-1]. Use two pointers....

Count subarrays with sum = k

Hard
5 views 23 Jan 2026
Task: return how many subarrays have sum exactly k (negative numbers allowed). Use prefix sum + hashmap....

Maximum product of any pair

Hard
4 views 23 Jan 2026
Task: values can be negative. Return maximum product of any two elements....

Merge two sorted arrays into first

Hard
4 views 23 Jan 2026
Task: a has size m+n, first m elements valid. b has n elements. Merge b into a in sorted order (in-place)....

Longest consecutive sequence length

Hard
4 views 23 Jan 2026
Task: return length of the longest consecutive sequence (order in array does not matter). Use HashSet....

Range add queries (difference array)

Hard
5 views 23 Jan 2026
Task: start with zeros of size n. Each query (l,r,add) adds add to every index in [l,r]. Return final array....