You are given a list of integers. Your task is to count how many increasing subsequences does the list contain.
You may assume that . The algorithm should be efficient in all these cases.
In a file countseq.py
, implement a function count
that returns the desired answer.
def count(t): # TODO if __name__ == "__main__": print(count([1, 1, 2, 2, 3, 3])) # 26 print(count([1, 1, 1, 1])) # 4 print(count([5, 4, 3, 2, 1])) # 5 print(count([4, 1, 5, 6, 3, 4, 1, 8])) # 37
Explanation: The list contains the increasing subsequences ( times), ( times), ( times), ( times), ( times), ( times) and ( times).