Rippling interview question

Generic Tree based DSA question