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,626–2,650
Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum. Walk through…
Companies: LinkedIn
Given a permutation nums of 0..n-1, determine whether every global inversion is also a local inversion (i.e., the counts are equal). This is equivalent to…
General practice
Parse a string made of tokens "G", "()" and "(al)" and return the concatenation after mapping each token to its interpretation ("G"→"G", "()"→"o", "(al)"→"al"). This…
General practice
Companies: Amazon, Infosys
Array · Math · Number Theory · Segment Tree
Given a list of tournament win records (player, tournament, year), determine which players have claimed all four Grand Slam titles (the Australian Open, French Open…
General practice
Graph Array Array String Questions
Companies: Uber
Given n and a threshold, determine for each query whether two nodes in 1..n are connected in the graph where an edge exists between x…
General practice
Given n labeled nodes and an undirected edge list, determine whether the edges form a valid tree — i.e., the graph is connected and contains…
General practice
Generate any sequence of 2^n distinct integers in [0, 2^n-1] starting at 0 such that consecutive numbers (and the first and last) differ by exactly…
General practice
Find the longest string x such that both str1 and str2 are formed by repeating x one or more times. Key insight: x must be…
General practice
Determine whether the graph on array indices with an edge between i and j iff gcd(nums[i], nums[j]) > 1 is fully connected. With nums and…
General practice
Find the alphabetically largest English letter that appears in the input string in both lowercase and uppercase forms, returning it as an uppercase character (or…
General practice
Choose a subset of array elements whose sum is maximized subject to being divisible by 3. Solve by tracking best achievable sums for each remainder…
General practice
Two players traverse a 2×n grid from (0,0) to (1,n-1), the first robot moves and zeros out its path then the second moves to maximize…
General practice
Given an n x n grid with some lamps that illuminate their entire row, column, and both diagonals, answer a sequence of queries asking whether…
General practice
Find the minimum moves from the top-left to bottom-right in a grid with obstacles where you can move 4-directionally and, for each uppercase letter at…
General practice
Add a groupBy(fn) method to arrays that returns an object mapping each string key produced by fn(item) to an array of items that produce that…
General practice
Given a list/table of employees with their names and salaries, group employees who share the same salary and return each salary with the corresponding list…
General practice
For each sell_date, deduplicate the products sold that day, count the distinct products, and return a lexicographically sorted comma-separated list of those product names…
General practice
Partition the people into disjoint groups so that each person i is in a group whose size equals groupSizes[i]; the task reduces to collecting indices…
General practice
Count the number of equivalence classes of strings under the relation that allows arbitrary swaps among even indices and among odd indices. Key idea: each…
General practice
Treat each string (letters are unique) as a 26-bit mask and connect two masks if one can be obtained from the other by adding or…
General practice
Given arrays customers and grumpy and an integer minutes, maximize total satisfied customers by choosing one contiguous minutes-long window to turn grumpy minutes into…
General practice
Find the minimum worst-case total cost to guarantee discovering a secret number in [1..n] when each wrong guess x costs x; this is an interval…
General practice