there party n friend number 0 n 1 attend there infinite number chair party number 0 infinity when friend arrive party sit unoccupied chair smallest numberfor example chair 0 1 5 occupy friend come sit chair number 2When friend leave party chair unoccupied moment leave if friend arrive moment sit chairYou give 0indexed 2D integer array times timesi arrivali leavingi indicate arrival leave times ith friend respectively integer targetfriend all arrival time distinctreturn chair number friend number targetfriend sit Example 1input time 142346 targetfriend 1output 1explanation Friend 0 arrive time 1 sit chair 0 friend 1 arrive time 2 sit chair 1 friend 1 leave time 3 chair 1 friend 0 leave time 4 chair 0 friend 2 arrive time 4 sit chair 0since friend 1 sit chair 1 return 1example 2input time 3101526 targetfriend 0output 2explanation Friend 1 arrive time 1 sit chair 0 friend 2 arrive time 2 sit chair 1 friend 0 arrive time 3 sit chair 2 friend 1 leave time 5 chair 0 friend 2 leave time 6 chair 1 friend 0 leave time 10 chair 2 emptySince friend 0 sit chair 2 return 2 Constraintsn timeslength2 n 104timesilength 21 arrivali leavingi 1050 targetfriend n 1each arrivali time distinct