you give 0indexed integer array bus length n busesi represent departure time ith bus you give 0indexed integer array passenger length m passengersj represent arrival time jth passenger all bus departure time unique all passenger arrival time uniqueyou give integer capacity represent maximum number passenger busWhen passenger arrive wait line available bus you bus depart x minute arrive y minutes y x bus Passengers early arrival time bus firstmore formally bus arrive eitherif capacity few passenger wait bus bus orthe capacity passenger early arrival time busReturn late time arrive bus station catch bus you arrive time passengernote the array bus passenger necessarily sort Example 1input bus 1020 passenger 2171819 capacity 2output 16explanation suppose arrive time 16at time 10 bus depart 0th passenger at time 20 second bus depart 1st passengernote arrive time passenger arrive 1st passenger catch busexample 2input bus 203010 passenger 1913264251121 capacity 2output 20explanation suppose arrive time 20at time 10 bus depart 3rd passenger at time 20 second bus depart 5th 1st passengersat time 30 bus depart 0th passenger younotice arrive later 6th passenger take seat bus Constraintsn buseslengthm passengerslength1 n m capacity 1052 busesi passengersi 109each element bus uniqueEach element passenger unique