Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution:
- def replaceElements(self, arr: List[int]) -> List[int]:
- # max to the right
- max_seen_so_far = -1
- for i in range(len(arr)-1, -1, -1):
- # first store thay you will use later before getting overwritten
- temp = arr[i]
- # this should be the first step that you should right
- # because of you have already obtained the answer from
- # the previous steps and that is what it is
- arr[i] = max_seen_so_far
- # you are literally doing this for the next step
- max_seen_so_far = max(max_seen_so_far, temp)
- return arr
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement