ProgrammingVery hardCodeforces-style · placement coding round

What is printed?

What is printed?
def cnt_inc(a, k):
    dp = [[0] * (k + 1) for _ in range(len(a))]
    for i in range(len(a)):
        dp[i][1] = 1
        for j in range(i):
            if a[j] < a[i]:
                for L in range(2, k + 1):
                    dp[i][L] += dp[j][L - 1]
    return sum(dp[i][k] for i in range(len(a)))
print(cnt_inc([1, 3, 2, 4], 2), cnt_inc([1, 3, 2, 4], 3))
  1. A. 5 2
  2. B. 6 2
  3. C. 5 3
  4. D. 4 2

Correct answer: A. 5 2

The increasing pairs of [1, 3, 2, 4] number 5, and the increasing triples are 1-3-4 and 1-2-4.

More Python Programming questions

Exams that ask this topic