fork download
  1. class Solution(object):
  2. def nextGreaterElement(self, nums1, nums2):
  3. """
  4. :type nums1: List[int]
  5. :type nums2: List[int]
  6. :rtype: List[int]
  7. """
  8. flage = False
  9. next_greater = []
  10. for num1 in nums1:
  11. # print(f'num is {num}')
  12. n2_index = nums2.index(num1)
  13. # print(f'index is {n2_index}')
  14. for num2 in nums2[n2_index:]:
  15. if num2 > num1:
  16. # print(f'add number {num2}')
  17. flage = True
  18. next_greater.append(num2)
  19. break
  20. if flage == False:
  21. # print(f"add -1 when num is {num1}")
  22. next_greater.append(-1)
  23. flage = False
  24. return next_greater
  25.  
Success #stdin #stdout 0.12s 14092KB
stdin
Standard input is empty
stdout
Standard output is empty