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 26–33
Transform a BST so each node's value becomes its original value plus the sum of all keys greater than it; this is typically done with…
Companies: Apple
Binary Search Tree · Binary Tree · Depth-First Search · Tree
Return the preorder (root–left–right) traversal of a binary tree as a list of node values. The recursive solution is trivial; the follow-up asks for an…
Companies: Meta
Binary Tree · Depth-First Search · Stack · Tree
Count pairs of nodes in a rooted tree whose path edge-letters can be rearranged into a palindrome — equivalently, the multiset of letters on the…
Companies: Goldman Sachs
Bit Manipulation · Depth-First Search · Hash Table · Tree
Given a weighted tree, remove edges so that each node's degree in the remaining forest is at most k while maximizing the total weight of…
Companies: LinkedIn, Uber
Depth-First Search · Dynamic Programming · Sorting · Tree
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
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 special binary tree where each internal node's value equals the minimum of its two children and every node has either 0 or 2…
Companies: LinkedIn
Binary Tree · Depth-First Search · Tree
Given a binary tree with unique node values, produce the shortest path from start node s to destination t as a string of 'L', 'R'…
Companies: Snowflake
Binary Lifting · Binary Tree · Depth-First Search · Lowest Common Ancestor