← Questions

Quickselect, distance between tree nodes, and substrings with a prefix

0
GoogleCodingLast asked Apr 2026

Three problems from one loop:

  1. Find the k-th largest element with quickselect. Compare the approaches and how to choose the pivot, then implement one.
  2. 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.
  3. 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.
Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding