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,101–2,125
Count the number of length-n sequences of 6-sided die rolls where face i cannot appear more than rollMax[i] consecutive times, returning the result modulo 1e9+7…
General practice
Given an array of daily calories and integers k, lower, and upper, compute the total score by evaluating the sum of every consecutive k-day window…
General practice
Compute the absolute difference between the element sum (sum of the array values) and the digit sum (sum of every decimal digit appearing in those…
General practice
Given a tree with node prices, choose a root to maximize the difference between the largest and smallest root-to-node path price sums; compute this maximum…
General practice
Given a binary m×n matrix, return a diff matrix where diff[i][j] = onesInRow(i) + onesInCol(j) - zerosInRow(i) - zerosInCol(j), i.e., the difference between the number…
General practice
For each cell in an m×n grid, compute answer[r][c] = |(# distinct values strictly on the diagonal above‑left of (r,c)) − (# distinct values strictly…
General practice
Given two potentially nested objects, produce a structured diff that lists paths where keys/values were added, removed, or changed. The challenge is to traverse both…
General practice
Given an arithmetic expression of nonnegative integers and operators (+, -, *), return all possible results from evaluating the expression under every valid parenthesization…
General practice
Count how many times each decimal digit appears in all integers within a given range (e.g., 1..n or low..high). This requires positional counting or digit-DP…
General practice
Find the minimum total cost to transform integer n into m by repeatedly incrementing or decrementing any single digit by 1 (digits remain same length)…
General practice
Implement a data structure of infinite fixed-capacity stacks that supports push to the leftmost stack with available space, pop from the rightmost non-empty stack, and…
General practice
Determine whether flipping at most one non-endpoint cell can eliminate every down/right path from (0,0) to (m-1,n-1) in a binary m×n grid. Because all monotonic…
General practice
Group orders by table and food item to count how many of each dish each table ordered, while collecting all distinct food names sorted alphabetically…
General practice
Return/display the first three rows of the employees DataFrame/table in their original order.
General practice
Given a circular array of distances between adjacent stops, compute the shortest distance between two stops by summing the distances along one direction and taking…
General practice
Given an undirected graph, return for every vertex the shortest distance to the nearest vertex that lies on any cycle. Key idea: identify cycle vertices…
Companies: Salesforce
Breadth-First Search · Depth-First Search · Graph Theory · Topological Sort
Rearrange an array of barcodes so that no two equal values are adjacent, knowing a solution always exists. The core challenge is to distribute high-frequency…
General practice
Count the number of distinct non-empty substrings of the given string that are "echoes" — even-length contiguous substrings whose first half equals the second half…
General practice
Given an array and window size k, return the number of distinct elements in every contiguous subarray of length k. The key challenge is to…
General practice
Count how many distinct prime numbers divide the product of all elements in an integer array — equivalent to aggregating the prime factors of each…
General practice