Skip to content

Commit 7f17417

Browse files
authored
Merge pull request neetcode-gh#3105 from Aasif853/Aasif-tecno-patch-1
Create 1299-replace-elements-with-greatest-element-on-right-side.rb
2 parents d68871c + 22c47cf commit 7f17417

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
def replace_elements(arr)
2+
right_max = -1
3+
(arr.length - 1).downto(0) do |i|
4+
cur_max = [right_max, arr[i]].max
5+
arr[i] = right_max
6+
right_max = cur_max
7+
end
8+
arr
9+
end

0 commit comments

Comments
 (0)