2
def findNumberOfLIS(self, nums: List[int]) -> int:4
if not nums or len(nums) == 0:7
def find_pos(sub, val):8
left, right = 0, len(sub) - 110
mid = (left + right) >> 120
if len(sub_list) == 0 or val > sub_list[-1][-1][0]:21
# should append a new element at the end23
sum([x[1] for x in sub_list[-1] if val > x[0]])27
sub_list.append([(val, cur_count)])29
# get the last number to turn it back to a LIS problem30
cur_sub = [array[-1][0] for array in sub_list]31
pos = find_pos(cur_sub, val)32
# if pos == 0, means it is smallest, no need to look the previous level and set it to be 134
sum([x[1] for x in sub_list[pos - 1] if val > x[0]])38
sub_list[pos].append((val, cur_count))40
return sum([x[1] for x in sub_list[-1]])