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 3,751–3,775
Partition word1 into contiguous substrings and for each substring you may apply operations—replace a single character, swap two characters, or reverse the substring—with the…
General practice
Given an uppercase string, repeatedly delete any occurrence of the substrings "AB" or "CD" (concatenation after deletions may create new occurrences) and return the minimum…
General practice
Companies: Amazon
Array · Hash Table · Sliding Window
Partition an array into the minimum number of contiguous subarrays such that each segment satisfies a given validity condition (e.g., no duplicates, a sum/xor property…
General practice
Find the smallest-length subsequence whose sum is strictly greater than the sum of the remaining elements; if multiple, pick the one with the larger total…
General practice
Partition the string into the fewest contiguous substrings such that each substring is "balanced" (every distinct character in the substring appears the same number of…
Companies: Grammarly
Counting · Dynamic Programming · Hash Table · String
Given a binary target string and an all-zero source, you may flip any suffix [i..n-1]; find the minimum number of such suffix-flip operations to obtain…
General practice
Given nums and k, repeatedly delete any contiguous subarrays whose sum is divisible by k to minimize the final array sum — equivalently, maximize the…
General practice
Given a positive four-digit integer, split its digits into two numbers (using all digits, leading zeros allowed) and return the minimum possible sum of those…
General practice
Find indices i < j < k with nums[i] < nums[j] and nums[k] < nums[j] (so nums[j] is a "peak") and return the minimum possible…
General practice
Find the minimum-sum "mountain" triplet i<j<k with nums[i]<nums[j]>nums[k] by treating each index as a potential peak j and locating the smallest elements to its left…
General practice
Given two arrays and up to k1 and k2 unit +/-1 edits, minimize the sum of (nums1[i]-nums2[i])^2 by optimally allocating k = k1+k2 operations to…
Companies: Google
Array · Binary Search · Greedy · Heap (Priority Queue)
Partition the array nums into m disjoint contiguous subarrays in order so that the bitwise AND of the i-th subarray equals andValues[i], and return the…
General practice
Determine each row's rightmost 1 and treat those positions as requirements to place at or before their row index; greedily for each row i find…
General practice
Companies: Amazon
Array · Counting · Greedy · Hash Table
Given a binary array, find the minimum number of swaps required to make all 1's contiguous by grouping them together; this reduces to locating a…
General practice
Given a binary circular array, find the minimum number of swaps needed to group all 1's contiguously anywhere in the circle. This reduces to finding…
General practice
Given two equal-length arrays where you may swap elements only at the same indices, find the minimum number of index-wise swaps to make both arrays…
General practice
Given an array of distinct positive integers, reorder it by increasing digit-sum (breaking ties by the smaller numeric value) and return the minimum number of…
General practice
Given an array and a target K, find the smallest threshold T such that when elements are classified by the threshold (e.g., "large" if >T…
General practice
Given a list of 24-hour times, compute the minimum minutes difference between any two time-points by treating times as minute values on a circular 24-hour…
General practice
Given n nodes and edges labeled with the time they are removed, find the minimum t such that deleting all edges with time <= t…
General practice