Rotate Function Leetcode Solution 862 Heads