Problem
Follow up
- Try to come up as many solutions as you can, there are at least 3 different ways to solve this problem.
- Could you do it in-place with O(1) extra space?
Java
Using Reverse
1 | class Solution { |
Submission Detail
- 35 / 35 test cases passed.
- Runtime: 0 ms, faster than 100.00% of Java online submissions for Rotate Array.
- Memory Usage: 39.4 MB, less than 97.56% of Java online submissions for Rotate Array.
brute force
1 | class Solution { |
Submission Detail
- 35 / 35 test cases passed.
- Runtime: 183 ms, faster than 22.49% of Java online submissions for Rotate Array.
- Memory Usage: 39.4 MB, less than 96.24% of Java online submissions for Rotate Array.