JUSPAY Interview Question

Question 3 based on tree and graph difficult