As reported: D. E. Shaw MTS screening round (Sept 2024): a DSA question, Binary Tree Cameras, followed by a system design discussion.
This is LeetCode 968 — Binary Tree Cameras. Our write-up: /binary-tree-cameras.
You are given the root of a binary tree. A camera placed on a node monitors that node, its parent and its immediate children. Return the minimum number of cameras needed to monitor every node.
Example 1
root = [0,0,null,0,0]
Output: 1
One camera on the root's left child watches all four nodes.
Example 2
root = [0,0,null,0,null,0,null,null,0]
Output: 2
Constraints: the tree has 1 to 1000 nodes; every Node.val == 0.
Code runner format: one JSON value per line: root as a level-order array with null for missing children. Implement minCameraCover(root).