there n student class number 0 n 1 the teacher student problem start student number 0 student number 1 teacher reach student number n 1 after teacher restart process start student number 0 againYou give 0indexed integer array chalk integer k there initially k piece chalk when student number give problem solve use chalki piece chalk solve problem however current number chalk piece strictly chalki student number ask replace chalkReturn index student replace chalk example 1input chalk 515 k 22output 0explanation the student turn follow student number 0 use 5 chalk k 17 Student number 1 use 1 chalk k 16 Student number 2 use 5 chalk k 11 Student number 0 use 5 chalk k 6 Student number 1 use 1 chalk k 5 Student number 2 use 5 chalk k 0student number 0 chalk replace itexample 2input chalk 3412 k 25output 1explanation the student turn follow student number 0 use 3 chalk k 22 Student number 1 use 4 chalk k 18 Student number 2 use 1 chalk k 17 Student number 3 use 2 chalk k 15 Student number 0 use 3 chalk k 12 Student number 1 use 4 chalk k 8 student number 2 use 1 chalk k 7 Student number 3 use 2 chalk k 5 student number 0 use 3 chalk k 2student number 1 chalk replace Constraintschalklength n1 n 1051 chalki 1051 k 109