Interview questions
Find a company or topic. Read the sources, then practice.
Loading the question library…
Find a company or topic. Read the sources, then practice.
Loading the question library…
Showing 151–175
Find all unique quadruplets of distinct elements in an integer array whose values sum to a given target. Results must avoid duplicates (order irrelevant); with…
Companies: Oracle
Array · Sorting · Two Pointers
Given two equal-length arrays, permute nums1 to maximize the number of positions where nums1[i] > nums2[i]. This is a greedy matching problem: sort nums1 and…
Companies: Walmart Labs
Array · Greedy · Sorting · Two Pointers
Given a circular binary array and integer k, count how many contiguous length-k segments are alternating (every adjacent pair within the segment differs). Because of…
Array · Sliding Window
Assign dry operations on zero days so that no lake is rained on while already full: given a sequence where rains[i]>0 fills a lake and…
Companies: MongoDB
Array · Binary Search · Greedy · Hash Table
Count the permutations of 1..n such that for every position i, either perm[i] is divisible by i or i is divisible by perm[i]. With n…
Companies: Rippling
Array · Backtracking · Bit Manipulation · Bitmask
Given an unsorted array, count the elements that are "binary searchable" — values that would be found by standard binary search without sorting, meaning every…
Companies: Uber
Array · Binary Search · Monotonic Stack · Stack
Support inserting obstacles at points on the nonnegative number line and, for each query, determine whether there exists any obstacle-free interval of length >= sz…
Companies: Hudson River Trading, Roblox, TikTok
Array · Binary Indexed Tree · Binary Search · Ordered Set
Given an integer array nums, produce ans by concatenating nums with itself so that ans has length 2n and ans[i]=nums[i], ans[i+n]=nums[i] for 0<=i<n; this is…
Companies: Bloomberg, Google
Array · Simulation
Given heights of vertical lines at unit-spaced x-coordinates, pick two indices i<j to maximize the area min(height[i],height[j])*(j-i). With n up to 1e5, the problem requires…
Companies: Amazon, Bloomberg, Cisco, Flipkart +4
Array · Greedy · Two Pointers
Find the maximum length of a contiguous subarray in a binary array that contains an equal number of 0s and 1s. This is solved by…
Companies: Cisco
Array · Hash Table · Prefix Sum
Companies: Microsoft
Array · Dynamic Programming · Prefix Sum
Count the number of contiguous subarrays that contain exactly k odd numbers in an integer array. The core challenge is to do this in linear…
Companies: TikTok
Array · Hash Table · Math · Prefix Sum
For each day in an array of daily temperatures, determine how many days you must wait until a warmer temperature appears (or 0 if none)…
Companies: Anduril, Chime, Goldman Sachs
Array · Monotonic Stack · Stack
Implement a fixed-size circular queue (ring buffer) supporting enqueue, dequeue, Front/Rear, isEmpty and isFull operations without using built-in queue types. The core…
Companies: NVIDIA
Array · Design · Linked List · Queue
Given a grid of integers (positive heal, negative damage) and moves only right or down, find the minimum positive initial health so the running health…
Companies: Intuit
Array · Dynamic Programming · Matrix
Implement an Encrypter that maps each character to a two-letter code and supports encrypting by replacing characters and decrypting by counting how many dictionary words…
Companies: Duolingo
Array · Design · Hash Table · String
Find all integers that occur exactly once in nums and whose immediate neighbors (x-1 and x+1) do not appear in the array; return these "lonely"…
Companies: Apple
Array · Counting · Hash Table
Given n people seated in a circle, repeatedly remove every k-th person clockwise until one remains and return their label — the classic Josephus problem…
Companies: Goldman Sachs
Array · Math · Queue · Recursion
Given an array of fruit types where you can pick from a contiguous sequence while carrying at most two distinct types (two baskets), return the…
Companies: Adobe, Amazon, Meta, Salesforce
Array · Hash Table · Sliding Window
Given positions of houses and heaters on a line, find the minimum uniform radius R such that every house is within distance R of some…
Companies: Anduril
Array · Binary Search · Sorting · Two Pointers
Given a list of (studentId, score) pairs, compute each student's average of their top five scores and return the results as (studentId, average) sorted by…
Companies: Goldman Sachs
Array · Hash Table · Heap (Priority Queue) · Sorting
Find the maximum area of a rectangle formed by contiguous bars in a histogram (given bar heights). The core challenge is determining each bar's maximal…
Companies: Bloomberg, Microsoft
Array · Monotonic Stack · Range Minimum/Maximum Query · Stack
Given an array of stone weights, repeatedly take the two heaviest stones, remove them, and if their weights differ push back the difference; return the…
Companies: Apple, Salesforce
Array · Heap (Priority Queue)
Split the stones into two groups to minimize the absolute difference of their total weights — equivalent to finding the largest subset sum ≤ total_sum/2…
Companies: Apple
0-1 Knapsack · Array · Dynamic Programming · Knapsack Problem
Given an array of integers, return the length of the longest strictly increasing subsequence; the core challenge is to compute this efficiently—naive DP is O(n^2)…
Companies: PayPal
Array · Binary Search · Dynamic Programming · Longest Increasing Subsequence