I'm attempting a leetcode problem, rotate array, and the solution I'm trying is being accepted when I run the code but not when I submit it, despite the fact that this solution is being suggested online. Problem: https://leetcode.com/problems/rotate-array/
My solution:
var rotate = function(nums, k) {
k = k % nums.length
let count = 0
while (count < k) {
nums.unshift(nums.pop())
count++
}
}
Edit: Problem solved thanks to the comments!