PhonePe interview question

DSA array and graph question (Mid level)