Rippling interview question

Binary lifting problem to find kth ancestor Connected graph problem