class Solution(object):
def isPossible(self, nums):
"""
:type nums: List[int]
:rtype: bool
"""
heaps = collections.defaultdict(list)
for num in nums:
if heaps[num - 1]:
prev_len = heapq.heappop(heaps[num - 1])
heapq.heappush(heaps[num], prev_len + 1)
else:
heapq.heappush(heaps[num], 1)
for cur_heap in heaps.values():
if cur_heap and cur_heap[0] < 3:
return False
return True