Skip to content

Commit b87ebf6

Browse files
Jian GUfishercoder1534
authored andcommitted
Update _189.java (fishercoder1534#40)
1 parent e45e928 commit b87ebf6

File tree

1 file changed

+14
-0
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+14
-0
lines changed

src/main/java/com/fishercoder/solutions/_189.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,18 @@ public static void rotate_naive(int[] nums, int k) {
7777
}
7878
}
7979
}
80+
81+
public static class Solution3 {
82+
public void rotate(int[] nums, int k) {
83+
int tmp = 0;
84+
for (int i = 0; i < k; i++) {
85+
tmp = nums[nums.length - 1];
86+
for (int j = nums.length - 1; j > 0; j--) {
87+
nums[j] = nums[j-1];
88+
}
89+
nums[0] = tmp;
90+
}
91+
}
92+
}
93+
8094
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy