• + 2 comments

    I did something similar, but I used mod in case

    K > arr.lenth + idx.