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 4,301–4,325
Count the number of index pairs (i, j) with 0 ≤ i < j < n such that nums[i] > 2 * nums[j]; this is…
Companies: eBay
Array · Binary Indexed Tree · Binary Search · Divide and Conquer
Find the first occurrence of character ch in word and reverse the prefix from index 0 up to that occurrence (inclusive), returning the modified string…
General practice
Reverse the input array of characters in-place (O(1) extra space) so the characters appear in reverse order; array length can be up to 10^5.
Companies: Meta
String · Two Pointers
Process the string in 2k-sized blocks and reverse the first k characters of each block. If fewer than k characters remain, reverse all of them…
General practice
Given an array, you may reverse one contiguous subarray to maximize the sum of absolute differences between adjacent elements; compute the maximum achievable array value…
General practice
Reverse only the vowels in a string (a, e, i, o, u, case-insensitive), leaving consonants and other characters in their original positions. This is a…
General practice
Given a string that may contain leading/trailing/multiple spaces, return a new string with the words in reverse order separated by a single space, removing any…
General practice
Given a character array representing a sentence with words separated by spaces, reverse the order of the words in-place (constant extra space, linear time) while…
General practice
Given lists of positive and negative words and one feedback report per student, compute each student's score (+3 per positive word, -1 per negative word)…
Companies: Booking.com
Array · Hash Table · Heap (Priority Queue) · Sorting
Given an m x n matrix where each row represents a customer's bank balances, compute each customer's wealth as the sum of their row and…
General practice
Count the number of axis-aligned right triangles formed by three 1s in a binary grid, where one vertex shares a row with a second 1…
General practice
Given 2-character color-position pairs describing up to 100 rings placed on rods labeled 0–9, count how many rods contain at least one ring of each…
General practice
Given a table of daily temperatures with unique dates, return the ids of days whose temperature is strictly higher than the immediate previous day (yesterday)…
General practice
Determine whether repeating a sequence of unit moves (G) and 90° turns (L/R) forever keeps a robot on the plane within some finite circle. Core…
General practice
Given robots with positions, healths and L/R directions that move simultaneously and collide when opposite-moving robots meet—where the lower-health robot is removed and the…
General practice
Determine whether a sequence of moves ('U','D','L','R') returns a robot to the origin by checking that the net horizontal and vertical displacements cancel out (i.e.…
General practice
Convert a valid Roman numeral string into its integer value by applying the additive and subtractive rules (e.g., IV = 4, IX = 9, CM…
Companies: Google, Microsoft
Hash Table · Math · String
Given a binary tree with exactly three nodes (a root and its left and right children), determine whether the root's value equals the sum of…
General practice
Given an array, maximize the rotation function F(k) = sum_{i=0}^{n-1} i * arr_k[i] over all k (rotating the array by k positions), with n up…
General practice
Check whether one string is a rotation of another: return true iff s and goal have the same length and goal can be obtained by…
Companies: Roblox
String · String Matching
Given an m x n binary matrix, find the 0-indexed row with the largest number of 1s (breaking ties by the smallest row index) and…
General practice