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,201–4,225
Given an even-length array with an equal number of positive and negative integers, produce a new array that starts with a positive and alternates signs…
General practice
Reorder the elements of an array to maximize the number of positive prefix sums — i.e., choose a sequence that keeps the running cumulative sum…
General practice
Given strings s and target, return the maximum number of copies of target you can form by taking letters from s and rearranging them; the…
General practice
Given anagram strings s and t and an integer k (with |s| divisible by k), determine whether you can split s into k equal-length contiguous…
General practice
Transform the Products table from a wide format to a long format by unpivoting the store1, store2, and store3 columns into rows of (product_id, store…
General practice
Given a string of words separated by spaces, redistribute all spaces so that adjacent words have an equal (maximized) number of spaces between them and…
General practice
Given a string and integer k, rearrange the characters so that identical characters are at least k positions apart (return an empty string if no…
General practice
Reorder the words of a sentence so they are in nondecreasing length, preserving original order for equal lengths, and return the sentence with the first…
General practice
Given two equal-length arrays, you can swap elements between them at cost min(a,b); determine the minimum total cost to make their sorted multisets identical or…
General practice
Reconstruct a 2×n binary matrix whose column sums equal the given colsum array and whose top and bottom row sums equal upper and lower respectively…
General practice
Given a jumbled string made from English words for digits 0–9, reconstruct the original digits in ascending order. Key idea: use character frequency counts and…
General practice
Reconstruct a binary tree from a preorder string where each node is represented by its value prefixed with D dashes indicating its depth (root depth…
Companies: Grammarly
Binary Tree · Depth-First Search · String · Tree
Given a multiset of 2n numbers that are exactly the values arr[i]-k and arr[i]+k for some unknown positive k, recover arr by finding a positive…
General practice
Check whether two axis-aligned rectangles have a positive-area intersection (touching edges or corners don't count) by verifying that their projections on both the x- and…
General practice
Given a Products table with columns product_id, low_fats, and recyclable, return the product_id values for rows where both low_fats and recyclable are 'Y'. The output…
General practice
Determine whether, by freely moving individual characters between strings, you can make all words identical; equivalently check that for every letter, its total count across…
General practice
Find the minimum number of distinct values to remove (deleting all their occurrences) so that at least half the array's elements are gone — equivalently…
General practice
Given an array of integer satisfaction levels (which may be negative), choose a subset and order of dishes—each taking 1 unit time—to maximize the like-time…
General practice
Repeatedly replace the current maximum element with the next smaller distinct value until all elements are equal, and return how many such reductions are needed…
General practice
Given edges of an undirected graph that started as a tree with one extra edge, find the edge whose addition creates a cycle and return…
General practice
Given a directed graph formed by adding one extra edge to a rooted tree, identify which single edge (returning the one that appears last in…
General practice
Convert a date like "20th Oct 2052" to "YYYY-MM-DD" by parsing the three parts, stripping the day's ordinal suffix, mapping the three-letter month to its…
General practice
Pivot the Department table into a wide format with one row per id and twelve columns (Jan_Revenue through Dec_Revenue) showing each department's revenue for that…
General practice