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 2,401–2,425
Given an array, produce a permutation (derangement) of its elements such that no element remains in its original index, or indicate that no such derangement…
General practice
Given strings s and t where t is a random permutation of s with one extra lowercase letter inserted, identify and return the added character…
General practice
Count how many elements in arr1 have no element in arr2 within distance d (i.e., for which every |arr1[i] - arr2[j]| > d). Arrays are…
General practice
Given a digit string and an integer m, return an array marking which prefixes of the string form numbers divisible by m; the core challenge…
General practice
Replace each character in s with the character k positions ahead in the original string, wrapping around the end (i.e., perform a cyclic index shift…
General practice
Given unique skill levels in queue order, repeatedly compare the first two players, keep the higher as the current champion (loser goes to the back)…
General practice
Identify every 3x3 subgrid whose adjacent pixels all differ by at most the threshold, compute each such region's floor-average intensity, and then for each pixel…
General practice
Given an array of altitude gains between consecutive points starting from altitude 0, compute the running cumulative altitudes (prefix sums) and return the maximum value…
General practice
Given a permutation of numbers 1..n, compute its lexicographic rank (index) among all permutations. The core challenge is counting how many permutations precede it efficiently…
General practice
Given two strings, return the starting index of the first occurrence of needle in haystack, or -1 if absent. This is a classic substring search…
Companies: Bloomberg, Google, Meta, Microsoft
Boyer–Moore String-Search Algorithm · Knuth–Morris–Pratt Algorithm · String · String Matching
Given an array of non-negative integers represented as strings, return the index of the largest integer — compare by string length first (longer means larger)…
General practice
Find the integer x such that adding x to every element of nums1 produces a multiset equal to nums2. Since nums2 is nums1 uniformly shifted…
General practice
Given two arrays where nums2 is formed by removing two elements from nums1 and adding the same integer x to every remaining element of nums1…
General practice
Count how many length-k contiguous substrings of num's decimal representation (leading zeros allowed) form nonzero integers that evenly divide num.
General practice
Compute the integer whose bit j is 1 iff at least k elements of nums have bit j set — equivalently, count ones per bit…
General practice
Given an integer array nums (n up to 1e5) and k ≤ min(2000, 2^n), return the k-th largest subsequence sum (the empty subsequence counts as…
General practice
An infinite string is formed by repeatedly appending a copy of the current string with each character advanced by one in the alphabet (wrapping 'z'→'a')…
General practice
Starting from "a", each operation appends either an identical copy or a +1-mod-26 shifted copy, causing the string to double repeatedly so its length can…
General practice
Generate the k-th positive integer whose decimal representation consists only of digits 4 and 7 (the "lucky" numbers), ordered by value. The challenge is to…
General practice
Given three positive integers (<=9999), pad each to four digits with leading zeros and construct a 4-digit number whose i-th digit is the minimum of…
General practice
Given an m×n matrix whose rows are sorted, pick exactly one element from each row and return the k-th smallest possible total sum; the challenge…
General practice
Find the largest integer that appears in exactly one contiguous subarray (sliding window) of length k in nums — return that integer or -1 if…
General practice
Find the largest n-digit palindrome (no leading zeros) divisible by k and return it as a string; with n up to 1e5 and k ≤…
General practice