there n room need visit label 0 n 1 each day label start 0 you visit room dayinitially day 0 visit room 0 the order visit room come day determine follow rule give 0indexed array nextvisit length nAssuming day visit room iif room odd number time include current visit day visit room low equal room number specify nextVisiti 0 nextVisiti iif room number time include current visit day visit room 1 mod nReturn label day room it show day exist since answer large return modulo 109 7 Example 1input nextVisit 00output 2explanation on day 0 visit room 0 the total time room 0 1 odd on day visit room nextvisit0 0 on day 1 visit room 0 the total time room 0 2 on day visit room 0 1 mod 2 1 on day 2 visit room 1 this day roomsExample 2input nextVisit 002output 6explanationyour room visit order day 0010012day 6 day roomsExample 3input nextvisit 0120output 6explanationyour room visit order day 0011223day 6 day room Constraintsn nextvisitlength2 n 1050 nextVisiti