Skip to content

Commit b31e371

Browse files
authored
Update booking-concert-tickets-in-groups.py
1 parent 90183bd commit b31e371

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

Python/booking-concert-tickets-in-groups.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ def update(self, i, h):
2727
self.tree[x] = self.query_fn(self.tree[x*2], self.tree[x*2+1])
2828

2929
def query(self, L, R):
30-
if L > R:
31-
return None
3230
L += self.base
3331
R += self.base
3432
left = right = None
@@ -83,7 +81,8 @@ def scatter(self, k, maxRow):
8381
:type maxRow: int
8482
:rtype: bool
8583
"""
86-
if k > self.__st.query(0, maxRow)[1]:
84+
cnt = self.__st.query(self.__i, maxRow)
85+
if not cnt or cnt[1] < k:
8786
return False
8887
for i in xrange(self.__i, maxRow+1):
8988
cnt = self.__st.tree[self.__st.base+i][1]

0 commit comments

Comments
 (0)