LeetCode #1299 “Replace Elements with Greatest Element on Right Side”

Opening

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