Solved LeetCode program · 935 of 1,000
#1299 · Replace Elements with Greatest Element on Right Side
Original English source
The numbers is a list of 17, 18, 5, 4, 6, and 1. The last is the last position of numbers. The answer is a list of last plus 1 zeros. The greatest is -1.
For every offset from 0 to last.
The spot is last minus offset. Set item spot of answer to greatest. If item spot of numbers is more than greatest, set greatest to item spot of numbers.
The line is empty text.
For each value in answer.
If the length of line is more than 0, Place "," into line. Place format whole number value as text into line.
Show line.
Expected stdout
18,6,6,6,1,-1