Question Bank
Every question, one list
Sandboxed coding rounds that run against a hidden test suite, and written questions graded against a rubric — side by side, because when you are drilling a topic you want both.
Topicimplementation (105)system-design (24)hld (20)trees (11)distributed-systems (10)arrays-hashing (9)concurrency (9)graphs (9)binary-search (8)consistency (8)dp-1d (8)linked-list (8)reliability (8)storage (8)
Clear filters11 questions · browse by bank instead
- Diameter of Binary TreeWrite `diameter_of_binary_tree(root)` returning the number of edges on the longest path between any two nodes. The path need not pass through the root. [1,2,3,4,5] -> 3 (4 -> 2 -> 1 -> 3) TheasyCoderpad#implementation#trees
- Invert Binary TreeWrite `invert_tree(root)` swapping every left and right child, and returning the root. The code is four lines. What the interviewer is listening for is whether you can name what you are doing — this easyCoderpad#implementation#trees
- Maximum Depth of Binary TreeWrite `max_depth(root)` returning the number of nodes on the longest path from the root down to a leaf. An empty tree has depth 0. The recursive answer is one line. The reason this is asked at all iseasyCoderpad#implementation#trees
- Subtree of Another TreeWrite `is_subtree(root, sub)` returning `True` when `sub` appears as a subtree of `root` — matching a node and *all* of its descendants exactly. This is two problems: an exact same-tree comparison, aeasyCoderpad#implementation#trees
- Binary Tree Level Order TraversalWrite `level_order(root)` returning a list of lists, one per level, top to bottom and left to right. [3,9,20,null,null,15,7] -> [[3], [9, 20], [15, 7]] A plain BFS visits nodes in the right ormediumCoderpad#implementation#trees
- Binary Tree Right Side ViewWrite `right_side_view(root)` returning the values visible when looking at the tree from the right, top to bottom. [1,2,3,null,5,null,4] -> [1, 3, 4] Walking down the right spine is the obvioumediumCoderpad#implementation#trees
- Kth Smallest Element in a BSTWrite `kth_smallest(root, k)` returning the kth smallest value (1-indexed) in the BST. An in-order traversal of a BST visits values in ascending order, so this is "stop after k visits." Collecting evmediumCoderpad#implementation#trees
- Lowest Common Ancestor of a BSTWrite `lowest_common_ancestor(root, p, q)` returning the deepest node that is an ancestor of both. Nodes are node objects, both present in the tree, and a node counts as its own ancestor. In a generamediumCoderpad#implementation#trees
- Validate Binary Search TreeWrite `is_valid_bst(root)` returning `True` when every node in the left subtree is strictly less than the node, and every node in the right subtree is strictly greater — for *all* nodes, not just immemediumCoderpad#implementation#trees
- Binary Tree Maximum Path SumWrite `max_path_sum(root)` returning the largest sum along any path between two nodes. The path follows parent-child edges, need not touch the root, and must contain at least one node. Values may be nhardCoderpad#implementation#trees
- Serialize and Deserialize Binary TreeImplement `serialize(root)` returning a string, and `deserialize(data)` rebuilding the tree, so that the round trip preserves the tree exactly. Pre-order with an explicit marker for every missing chihardCoderpad#implementation#trees