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 1,701–1,725
Given a target string and two operations—append the next character at cost addCost or copy any substring that already appears in the built prefix at…
General practice
Given a multiset of lowercase letters and an integer repeatLimit, build the lexicographically largest string (you may omit characters) such that no letter appears more…
General practice
Determine whether a target array can be formed from an all-ones array by repeatedly replacing an element with the current total sum; solve by reversing…
General practice
Construct a length 2n-1 sequence where 1 appears once and each i∈[2,n] appears twice with exactly i indices between its two occurrences, and return the…
General practice
Given counts of blocks "AA", "BB", and "AB", choose and order some blocks to build the longest concatenated string that does not contain "AAA" or…
General practice
For each prime p in nums, find the smallest nonnegative integer x such that x OR (x+1) == p, or return -1 if no such…
General practice
For each prime p in nums, find the smallest nonnegative integer x such that x OR (x+1) == p (or return -1 if no such…
General practice
Given a positive integer area, find integers L >= W with L * W = area that minimize the difference L - W; equivalently return…
General practice
Companies: Amazon, Amdocs, Google, Meta +1
Array · Math
Companies: Amazon, Amdocs, Google
Array · Math
Given a target sequence or multiset of numbers, decide whether you can construct two strictly increasing arrays that satisfy the problem's element-wise/combined constraints…
General practice
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
Given an array and integers indexDiff and valueDiff, determine whether there exist distinct indices i and j with |i - j| ≤ indexDiff and |nums[i]…
General practice
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
Count the number of contiguous subarrays whose elements all differ pairwise by at most 2 (equivalently max - min ≤ 2). With n up to…
General practice
Given a 1D array, reshape it into an m×n 2D array by grouping consecutive elements into rows (row-major order); return an empty array if original.length…
General practice
Convert a 32-bit signed integer to its lowercase hexadecimal string representation, using two’s complement for negative values and omitting leading zeros (except for "0")…
General practice
Given an integer array, partition its elements into the minimum number of rows so that each row contains only distinct values; return any valid 2D…
General practice
General practice
Write a wrapper that converts a Node-style callback function (error-first callback as the last argument) into a Promise-returning function: call the original with any given…
General practice
Given a date in a human-readable form like "20th Oct 2052", parse and convert it to ISO "YYYY-MM-DD" by stripping ordinal suffixes from the day…
General practice
Given a date string in "yyyy-mm-dd" format, convert the year, month, and day separately to their binary representations without leading zeros and return them joined…
General practice
Find two positive integers a and b whose decimal representations contain no digit 0 (no-zero integers) such that a + b = n, and return…
General practice