Skip to content

Commit

Permalink
Create 1299-replace-elements-with-great ... .dart
Browse files Browse the repository at this point in the history
  • Loading branch information
laitooo committed Jan 8, 2023
1 parent ff32745 commit 7d82c4e
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class Solution {
List<int> replaceElements(List<int> arr) {
var curMax = -1;
for (int i = arr.length - 1; i > -1; i--) {
int newMax = max(curMax, arr[i]);
arr[i] = curMax;
curMax = newMax;
}
return arr;
}
}

0 comments on commit 7d82c4e

Please sign in to comment.