Tap here to switch tabs
Problem
Submissions

Problem: Replace Elements with Greatest Element on Right Side

med
30 min
Try to solve the Replace Elements with Greatest Element on Right Side problem.

Statement

Given an integer array arr, replace every element in the array with the greatest element among all elements to its right, and replace the final element with −1-1.

Return the modified array.

Constraints:

  • 1≤1 \leq arr.length ≤104\leq 10^4

  • 1≤1 \leq arr[i] ≤105\leq 10^5

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Replace Elements with Greatest Element on Right Side

med
30 min
Try to solve the Replace Elements with Greatest Element on Right Side problem.

Statement

Given an integer array arr, replace every element in the array with the greatest element among all elements to its right, and replace the final element with −1-1.

Return the modified array.

Constraints:

  • 1≤1 \leq arr.length ≤104\leq 10^4

  • 1≤1 \leq arr[i] ≤105\leq 10^5