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,826–2,850
Given an array of integers, find the largest value that appears exactly once; return -1 if no unique number exists. This requires counting frequencies (e.g.…
General practice
Select up to numWanted items to maximize the total value, with the constraint that no label can be chosen more than useLimit times. This is…
General practice
Given an r×c grid where cells become water each day in a given order, find the last day when there still exists a 4-directional path…
General practice
Given a plank of length n and arrays of ant positions moving left or right, compute when the last ant falls off. Key insight: collisions…
General practice
Order the people by their turn and compute a running total of weights, then return the person_name of the last person whose addition keeps the…
General practice
Given an array of stone weights, repeatedly take the two heaviest stones, remove them, and if their weights differ push back the difference; return the…
Companies: Apple, Salesforce
Array · Heap (Priority Queue)
Split the stones into two groups to minimize the absolute difference of their total weights — equivalent to finding the largest subset sum ≤ total_sum/2…
Companies: Apple
0-1 Knapsack · Array · Dynamic Programming · Knapsack Problem
Return the lexicographically largest substring of s, i.e., the maximum among all suffixes and substrings starting at any index. Because n can be large (≤4·10^5)…
General practice
Scan nums keeping a stack (most-recent-first) of positive integers and a counter of consecutive -1s. When you see a positive, push it and reset the…
General practice
Given a time string "hh:mm" with some digits replaced by '?', replace each '?' to form the latest possible valid 24-hour time (00:00–23:59). The challenge…
General practice
Given a "HH:MM" 12-hour time string with some digits replaced by '?', replace all '?' to form the latest valid time (hours 00–11, minutes 00–59)…
General practice
Companies: Airbnb
Leader principles: challenging project and beyond above LeetCode copy linked list
Companies: Amazon
Aggregate teams' match results into per-team statistics (points, wins/draws/losses, goals for/against) and produce a ranked leaderboard according to specified tie-breakers…
General practice
Given x and a target, form an expression using only repeated x's combined with +, -, *, / (no parentheses, standard precedence) that equals target…
General practice
Companies: Snap
Companies: Citadel