MCPcopy Create free account
hub / github.com/HuberTRoy/leetCode / next

Method next

Design/RLEIterator.py:62–76  ·  view source on GitHub ↗

:type n: int :rtype: int

(self, n)

Source from the content-addressed store, hash-verified

60 self.a = A
61
62 def next(self, n):
63 """
64 :type n: int
65 :rtype: int
66 """
67 for i in range(0, len(self.a), 2):
68 if self.a[i] > 0:
69 if self.a[i] - n >= 0:
70 self.a[i] -= n
71 return self.a[i+1]
72 else:
73 t = self.a[i]
74 self.a[i] -= n
75 n -= t
76 return -1
77
78
79# Your RLEIterator object will be instantiated and called as such:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected