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

Commit6c7d445

Browse files
authored
Merge pull requestneetcode-gh#1251 from tharunkanna14/patch-3
Create 1299_replace_elements_with_greatest_element_on_right_side.java
2 parentsa35232f +45d7093 commit6c7d445

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
classSolution {
2+
publicint[]replaceElements(int[]arr) {
3+
intrightMax = -1;
4+
for (inti =arr.length -1;i >=0;i--) {
5+
intnewMax =Math.max(rightMax,arr[i]);
6+
arr[i] =rightMax;
7+
rightMax =newMax;
8+
}
9+
returnarr;
10+
}
11+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp