4 views
23 Jan 2026
Task: given array, compute running total array where res[i]=sum upto i....
4 views
23 Jan 2026
Task: return [posCount, negCount, zeroCount] for the array....
5 views
23 Jan 2026
Task: return [min,max] in one pass using two variables....
4 views
23 Jan 2026
Task: swap two ints without temp using + and - and return [b,a]....
5 views
23 Jan 2026
Task: return index of maximum value (first occurrence)....
5 views
23 Jan 2026
Task: return sum of every window of size k as long array....
4 views
23 Jan 2026
Task: starting balance and transactions array (+credit, -debit). Return first index where balance becomes negative, else -1....
5 views
23 Jan 2026
Task: return prefix minimum array where res[i]=min(a[0..i])....
4 views
23 Jan 2026
Task: show variable shadowing safely by computing result with local variables only....
6 views
23 Jan 2026
Task: answer queries (l,r) for number of distinct values. Use Mo's algorithm outline....
4 views
23 Jan 2026
Task: apply updates (+x) but also handle rollback to previous savepoint index. Return final value....
6 views
23 Jan 2026
Task: given timestamps in seconds, allow at most limit events in last window seconds. Return allowed count....
5 views
23 Jan 2026
Task: return max profit with at most 2 buy-sell transactions. Use variables for DP states....
4 views
23 Jan 2026
Task: reverse the given int array without using another array. Try using two pointers (start/end) and swap....
4 views
23 Jan 2026
Task: return how many values are even in the given int array. Keep it simple with one loop....
5 views
23 Jan 2026
Task: return true if the array is sorted in non-decreasing order. Compare adjacent elements....
4 views
23 Jan 2026
Task: return the maximum value from a non-empty array....
5 views
23 Jan 2026
Task: return sum of all elements in the array....
9 views
23 Jan 2026
Task: move all zeros to the end while keeping the relative order of non-zero elements....
5 views
23 Jan 2026
Task: rotate the array to the right by k steps without extra array. Use reverse trick....
6 views
23 Jan 2026
Task: return the second largest distinct value. If it does not exist, return Integer.MIN_VALUE....
6 views
23 Jan 2026
Task: array has n-1 numbers from 1..n without duplicates. Return the missing number....
3 views
23 Jan 2026
Task: array is sorted. Return indices of two numbers that sum to target, else [-1,-1]. Use two pointers....
5 views
23 Jan 2026
Task: return how many subarrays have sum exactly k (negative numbers allowed). Use prefix sum + hashmap....
4 views
23 Jan 2026
Task: values can be negative. Return maximum product of any two elements....
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)....
4 views
23 Jan 2026
Task: return length of the longest consecutive sequence (order in array does not matter). Use HashSet....
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....
5 views
23 Jan 2026
Task: create a List and add all given numbers in the same order....
5 views
23 Jan 2026
Task: remove duplicates from a list but keep first-seen order. Return the cleaned list....
5 views
23 Jan 2026
Task: return a map of number -> frequency from the given int array....
6 views
23 Jan 2026
Task: implement a small stack using Deque and support push/pop/peek....
4 views
23 Jan 2026
Task: process operations on a queue (offer and poll). Return final size....
8 views
23 Jan 2026
Task: return the first number that appears exactly once in the list, else return null....
5 views
23 Jan 2026
Task: return k numbers with highest frequency. If tie, any order is fine....
5 views
23 Jan 2026
Task: group numbers by (value % m) and return a map remainder -> list of numbers....
4 views
23 Jan 2026
Task: for each window of size k, return max. Use deque of indices....
5 views
23 Jan 2026
Task: sort Student by marks (desc), then id (asc)....
4 views
23 Jan 2026
Task: implement a small LRU cache using LinkedHashMap. Support get/put with capacity....
6 views
23 Jan 2026
Task: given n and edges, detect if there is a cycle (directed). Use DFS + recursion stack....
5 views
23 Jan 2026
Task: given intervals, merge overlapping ones and return merged list....
5 views
23 Jan 2026
Task: merge k sorted int arrays into one sorted array using a priority queue....
3 views
23 Jan 2026
Task: for each i, consider last k numbers ending at i. Return the max frequency seen in any window....
5 views
23 Jan 2026
Task: return sum of numbers from 1..n that are divisible by 3. Use loop and if condition....
4 views
23 Jan 2026
Task: return how many digits are in an integer. Handle 0 properly....
4 views
23 Jan 2026
Task: reverse digits of a number and return result (ignore overflow for now)....
4 views
23 Jan 2026
Task: return true if year is leap year using correct rules (divisible by 400, or divisible by 4 but not 100)....
5 views
23 Jan 2026
Task: return total stars printed in a triangle of height n (1+2+...+n)....
5 views
23 Jan 2026
Task: count how many numbers in 1..n would print FizzBuzz (div by 3 and 5)....
4 views
23 Jan 2026
Task: return nth Fibonacci number (0-indexed) using iterative loop....
5 views
23 Jan 2026
Task: return gcd(a,b) using while loop (Euclid algorithm)....
3 views
23 Jan 2026
Task: return the first prime number that is >= n....
4 views
23 Jan 2026
Task: given balance and withdrawals array, process in order. If withdrawal > balance skip it. Return final balance....
4 views
23 Jan 2026
Task: you can add 1 or 2 each move. Return minimum moves to reach exactly n....
5 views
23 Jan 2026
Task: grid has 0 (free) and 1 (blocked). Return number of paths from (0,0) to (m-1,n-1) moving right/down....
5 views
23 Jan 2026
Task: given a char array containing '(', ')', return true if it is balanced....
4 views
23 Jan 2026
Task: return the first index where a[i] >= target in a sorted array, else return n....
4 views
23 Jan 2026
Task: return maximum subarray sum (at least one element)....
4 views
23 Jan 2026
Task: return true if x can fit in a signed byte (-128..127)....
4 views
23 Jan 2026
Task: given a digit character '0'..'9', return its integer value....
4 views
23 Jan 2026
Task: return absolute difference between two ints as a long (avoid overflow)....
7 views
23 Jan 2026
Task: return true if all characters are digits and length > 0....
5 views
23 Jan 2026
Task: parse a binary string (like 10110) and return integer value....
6 views
23 Jan 2026
Task: clamp x into [low, high] and return clamped value....
6 views
23 Jan 2026
Task: return true if two doubles are almost equal using epsilon....
5 views
23 Jan 2026
Task: return number of set bits (1s) in binary representation of x....
4 views
23 Jan 2026
Task: return average of two ints without overflow....
6 views
23 Jan 2026
Task: return true if a+b overflows 32-bit int....
6 views
23 Jan 2026
Task: given total seconds, return [hours, minutes, seconds]....
6 views
23 Jan 2026
Task: compute a^b using fast exponentiation (b >= 0)....
6 views
23 Jan 2026
Task: pack two 32-bit ints (a,b) into one long and unpack later....
7 views
23 Jan 2026
Task: compute checksum = sum(i*value) mod 1e9+7 for array values....
5 views
23 Jan 2026
Task: return digits of a non-negative number in correct order....
4 views
23 Jan 2026
Task: divide a by b and throw ArithmeticException when b is 0....
6 views
23 Jan 2026
Task: if x is negative, throw IllegalArgumentException. Else return x....
7 views
23 Jan 2026
Task: parse integer from string; if invalid, return fallback value....
5 views
23 Jan 2026
Task: return a[index] if valid else throw IndexOutOfBoundsException....
4 views
23 Jan 2026
Task: if obj is null throw NullPointerException else return it....
3 views
23 Jan 2026
Task: show a method that closes a Closeable safely in finally without hiding original exception....
4 views
23 Jan 2026
Task: create a custom exception InsufficientBalanceException and throw it when withdraw > balance....
5 views
23 Jan 2026
Task: age must be 1..120. If not, throw IllegalArgumentException....
6 views
23 Jan 2026
Task: wrap IOException into RuntimeException and rethrow....
4 views
23 Jan 2026
Task: validate (nameLength > 0) and (score between 0..100). Throw IllegalArgumentException if any fails....
5 views
23 Jan 2026
Task: update two array positions. If any index is invalid, keep array unchanged and throw exception....
7 views
23 Jan 2026
Task: call a risky operation and retry up to 3 times on exception. If still fails, throw last exception....
5 views
23 Jan 2026
Task: if array is not sorted, throw IllegalStateException. Else return true....
5 views
23 Jan 2026
Task: wrap exception with cause and rethrow as RuntimeException keeping original cause....
4 views
23 Jan 2026
Task: simulate primary exception and also close exception; ensure primary is thrown....
4 views
23 Jan 2026
Task: swap a[i] and a[j] in an int array....
4 views
23 Jan 2026
Task: create and return a new array copy without using Arrays.copyOf....
4 views
23 Jan 2026
Task: return first index of target in array, else -1....
4 views
23 Jan 2026
Task: return how many times target appears in array....
4 views
23 Jan 2026
Task: return minimum value from non-empty array....
5 views
23 Jan 2026
Task: reverse elements between l and r inclusive....
4 views
23 Jan 2026
Task: remove all occurrences of val in-place and return new length (order can change)....
4 views
23 Jan 2026
Task: merge a and b alternately into a new array. Extra tail should be appended at end....
5 views
23 Jan 2026
Task: return prefix sums where pref[i] = sum of a[0..i]....
4 views
23 Jan 2026
Task: assume there is a majority element (> n/2). Return it using O(1) space....
3 views
23 Jan 2026
Task: return unique intersection of a and b....
4 views
23 Jan 2026
Task: given positive integers, return min length subarray with sum >= target. If not found return 0....
4 views
23 Jan 2026
Task: place negative numbers first then non-negative, keeping relative order inside each group....
5 views
23 Jan 2026
Task: return number of inversions in array using merge sort....
7 views
23 Jan 2026
Task: return array where res[i] = product of all elements except a[i] (no division)....
4 views
23 Jan 2026
Task: return true if integer reads same from left to right....
5 views
23 Jan 2026
Task: return count of vowels (a,e,i,o,u) in given char array (lowercase)....
6 views
23 Jan 2026
Task: return true if two char arrays are anagrams (same letters with same counts)....
4 views
23 Jan 2026
Task: return factorial of n (n>=0) using loop....
5 views
23 Jan 2026
Task: return true if x is power of two....
5 views
23 Jan 2026
Task: write a reusable method lowerBound for sorted array. Return first index with value >= target....
5 views
23 Jan 2026
Task: return first index where a[i] > target in sorted array....
5 views
23 Jan 2026
Task: compress chars by counting consecutive same characters. Return new length....
5 views
23 Jan 2026
Task: given lowercase letters, return index of first non-repeating char, else -1....
4 views
23 Jan 2026
Task: validate 4 parts (0..255) without leading plus. Input as int[4]....
5 views
23 Jan 2026
Task: build a helper method that returns a LinkedHashMap with accessOrder enabled....
4 views
23 Jan 2026
Task: decode pairs (value,count) into an array....
5 views
23 Jan 2026
Task: evaluate postfix expression given as int tokens and ops codes. Use stack....
5 views
23 Jan 2026
Task: build prefix function (lps) for pattern char array (classic KMP)....
4 views
23 Jan 2026
Task: return median of two sorted arrays using merge-like walk (O(n+m))....
7 views
23 Jan 2026
Task: create a class Account with private balance and methods deposit/withdraw....
5 views
23 Jan 2026
Task: create Point with (x,y) and also default constructor (0,0)....
6 views
23 Jan 2026
Task: create Shape base and Rectangle child overriding area()....
4 views
23 Jan 2026
Task: create interface Computation and a class Add that implements it....
4 views
23 Jan 2026
Task: create immutable Pair (a,b) with equals and hashCode....
6 views
23 Jan 2026
Task: create a class Team holding int[] scores. Use defensive copy in constructor....
5 views
23 Jan 2026
Task: implement Comparable for Student by marks desc then id asc....
4 views
23 Jan 2026
Task: create static factory for Rectangle to validate inputs (w,h > 0)....
5 views
23 Jan 2026
Task: create Logger used inside Service (composition). Provide method logCount....
4 views
23 Jan 2026
Task: create interface Billable and two implementations. Return total bill for array of Billable....
5 views
23 Jan 2026
Task: implement strategy to pick sort key from object and sort list accordingly....
6 views
23 Jan 2026
Task: implement a Counter class with increment and get methods thread-safe using synchronized....
4 views
23 Jan 2026
Task: clone a linked list node chain without sharing nodes....
4 views
23 Jan 2026
Task: implement a Builder for User with optional fields id and age....
4 views
23 Jan 2026
Task: design equals for base class without breaking symmetry (use final class)....
5 views
23 Jan 2026
Task: return a & b....
4 views
23 Jan 2026
Task: return true if x is odd using bitwise operator....
4 views
23 Jan 2026
Task: swap a[i] and a[j] using XOR (only if i!=j)....
5 views
23 Jan 2026
Task: set k-th bit (0-indexed) in x and return result....
5 views
23 Jan 2026
Task: clear k-th bit (0-indexed) in x and return result....
7 views
23 Jan 2026
Task: toggle k-th bit and return result....
7 views
23 Jan 2026
Task: return lowest set bit value (like x & -x). If x==0 return 0....
5 views
23 Jan 2026
Task: count set bits using x &= (x-1) loop....
5 views
23 Jan 2026
Task: return true if k-th bit is set....
4 views
23 Jan 2026
Task: create bitmask with bits l..r set (inclusive)....
5 views
23 Jan 2026
Task: reverse bits of int and return result....
4 views
23 Jan 2026
Task: in array where every number appears twice except one, return the single number using XOR....
4 views
23 Jan 2026
Task: every number appears twice except two numbers. Return the two unique numbers....
5 views
23 Jan 2026
Task: given masks a and b, return true if b is subset of a (all bits in b also set in a)....
5 views
23 Jan 2026
Task: return 0 if number of set bits is even, 1 if odd....
4 views
23 Jan 2026
Task: swap two integers a and b and return as array [b,a]....
6 views
23 Jan 2026
Task: increment x by 1 and return the new value....