GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — Leetcode-Java/leetcode/solution/src/RotateArray.java at master · Tulpen/Leetcode-Java Expand file tree/ Copy pathRotateArray.javaMore file actions 19 lines (17 loc) · 473 Bytes / Copy pathRotateArray.javaFile metadata and controls19 lines (17 loc) · 473 Bytes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 public class RotateArray { public void rotate(int[] nums, int k) { k %= nums.length; reverse(nums, 0, nums.length - 1); reverse(nums, 0, k - 1); reverse(nums, k, nums.length - 1); } public void reverse(int[] nums, int start, int end) { while (start < end) { int temp = nums[start]; nums[start] = nums[end]; nums[end] = temp; start++; end--; } } } |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |