Skip to content
DeepForgeby svx
All problems
MediumProbabilitypr-323

Stirling Second Kind Count

Problem

The Stirling number of the second kind S(n, k) counts partitions of n labeled items into k nonempty unlabeled blocks, via S(n, k) = k S(n-1, k) + S(n-1, k-1).

Given n and k, return S(n, k).

Hint

Either join one of the existing blocks or start a new block.

Test cases

case 1
in: [4,2]
expected: 7
case 2
in: [5,3]
expected: 25
case 3
in: [3,3]
expected: 1
Starter codePython
def stirling_second_kind_count(n, k):
    # Your code here
    pass

3 test cases · run your code against them in the editor