Solving Replace Elements with Greatest Element on Right Side in go. Please try yourself first to solve the problem and submit your implementation to LeetCode before looking into solution.

Problem Description

After doing so, return the array.

Example 1:

Input: arr = [17,18,5,4,6,1]
Output: [18,6,6,6,1,-1]

Constraints:

  • 1 <= arr.length <= 10^4

  • 1 <= arr[i] <= 10^5

  • 1 <= arr.length <= 10^4

  • 1 <= arr[i] <= 10^5

See the full details of the problem Replace Elements with Greatest Element on Right Side at LeetCode

Originally posted at: @github.com/halfrost/LeetCode-Go