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,076–4,100
Given sorted values nums and a threshold maxDiff, determine for each query whether two node indices lie in the same connected component of an undirected…
General practice
Given n and array nums, build an undirected unweighted graph where an edge exists between i and j iff |nums[i] - nums[j]| ≤ maxDiff, and…
General practice
Given a node label in an infinite binary tree whose rows alternate left-to-right and right-to-left labeling, return the sequence of labels from the root to…
General practice
Count how many downward paths (parent→child, can start and end at any nodes) in a binary tree sum to a given target. The challenge is…
Companies: TikTok
Binary Tree · Depth-First Search · Tree
Find the maximum sum of gold collectible by walking a path on an m x n grid that starts at any nonzero cell, moves up/down/left/right…
General practice
Find the path from start to end in an undirected graph that maximizes the product of edge success probabilities (return 0 if unreachable). This is…
General practice
Find a path from the top-left to bottom-right of a 4-directional height grid that minimizes the route's effort, defined as the maximum absolute difference between…
General practice
Count the number of down/right paths from the top-left to bottom-right of a grid whose path-sum is divisible by k, returning the result modulo 1e9+7…
General practice
Given a maze where each cell deterministically leads to a next cell (or movement continues until blocked), determine which starting cells eventually end up in…
General practice
Return patient_id, patient_name, and conditions for patients whose space-separated conditions list contains a condition code that begins with the prefix "DIAB1" (i.e., a token…
General practice
Given an array where a "peak" is an element greater than its immediate neighbors, process up to 1e5 queries that either update a single element…
General practice
Given an array of each person's favorite-company lists, return the indices (in increasing order) of lists that are not a subset of any other list…
General practice
Count how many times a given character appears in a string and return the percentage that count represents of the string length, rounded down to…
General practice
For each contest, compute the percentage of all users (distinct user count from the Users table) who registered for that contest (registered users / total…
General practice
Check whether a positive integer equals the sum of its proper positive divisors (excluding itself); the core challenge is efficiently finding and summing divisor pairs…
General practice
Given a list of axis-aligned rectangles, determine whether they exactly form a single rectangular region — i.e., their union equals one rectangle with no gaps…
General practice
Given n (1 ≤ n ≤ 10^4), find the minimum number of perfect square numbers that sum to n. This is essentially a coin-change/shortest-path problem…
General practice
Given a string and a list of shift operations (each a direction and amount), compute the final string after applying all shifts; the key is…
General practice
Given two strings s and t where t is a permutation of s and each character is unique, compute the permutation difference defined as the…
General practice
Return the k-th lexicographic permutation of [1..n] without generating all permutations — compute it directly by greedily selecting each digit using combinatorial block sizes…
General practice
Given a sequence (possibly containing duplicate elements), compute its unique permutations—either enumerate all distinct permutations or return the k-th permutation in…
General practice
Return the k-th lexicographically-sorted permutation of 1..n whose adjacent elements alternate parity (no two consecutive odds or evens). With n up to 100 and k…
General practice
Given a list of phone numbers (strings), determine whether the list is "consistent" by checking if any number is a prefix of another. Efficient solutions…
General practice
Phone Screen: Two classic leetcode problems in the Top 30 list. One tests binary search in a sorted array, another one tests graph search using…
Companies: Meta