Python 3 Editorial solution is O(n^2)


#1

hasNode is O(n) and it is called by findAncestor O(n) times