Hello all,with best of my knowledge I wrote my 3rd graph solution for this question.I spent so much time thinking on it but after submitting it,it gave out TLE.As i am amateur in Graphs,I will be obliged if some one come out for help :) link of my code