My LeetCode grinding. Trying to do a problem a day.
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

123456789101112131415
  1. class Solution:
  2. def replaceElements(self, arr):
  3. res = []
  4. for (ind, n) in enumerate(arr[0:len(arr)-1]):
  5. biggest = arr[ind + 1]
  6. for x in arr[ind + 1:]:
  7. if x > biggest:
  8. biggest = x
  9. res.append(biggest)
  10. res.append(-1)
  11. return res
  12. s = Solution()
  13. print("Expected: [18,6,6,6,1,-1]")
  14. print("Got:", s.replaceElements([17,18,5,4,6,1]))