Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbc3bcf1

Browse files
Jian GUfishercoder1534
Jian GU
authored andcommitted
Update _189.java (#40)
1 parent40e6a5c commitbc3bcf1

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+
publicstaticclassSolution3 {
82+
publicvoidrotate(int[]nums,intk) {
83+
inttmp =0;
84+
for (inti =0;i <k;i++) {
85+
tmp =nums[nums.length -1];
86+
for (intj =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)

[8]ページ先頭

©2009-2025 Movatter.jp