Generate the next lexicographic array arrangement | DoorDash Interview Question