My LeetCode grinding. Trying to do a problem a day.
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

main.py 428B

123456789101112131415
  1. class Solution:
  2. def peakIndexInMountainArray(self, A):
  3. # return the peak of the mountain... i.e Where the array starts going down in value
  4. last = -1
  5. for ind, n in enumerate(A):
  6. if n < last:
  7. return ind - 1
  8. last = n
  9. # This should never happen
  10. return -1
  11. s = Solution()
  12. print("Expected: 1")
  13. print("Got:", s.peakIndexInMountainArray([0, 2, 1, 0]))