K L University interview question

DSA question on depth first search