Quickselect, distance between tree nodes, and substrings with a prefix
Three problems from one loop:
- Find the k-th largest element with quickselect. Compare the approaches and how to choose the pivot, then implement one.
- Given the edges of a tree and two nodes, return how far apart they are. Clarify duplicate edges, whether the edges always form a tree, and missing or identical nodes.
- Given a string and a target, count the substrings that start with the target. Follow-up: the length of the shortest substring that contains the target.
No answer yet. Write the first one; the best answer gets endorsed.
