Skip to content
DeepForgeby svx
All problems
EasyProbabilitypr-331

Permutations with Repetition

Problem

The number of length-k sequences drawn from n distinct symbols with repetition allowed is n^k.

Given n and k, return the count.

Hint

Each position has n independent choices.

Test cases

case 1
in: [2,3]
expected: 8
case 2
in: [10,0]
expected: 1
case 3
in: [4,2]
expected: 16
Starter codePython
def permutations_with_repetition(n, k):
    # Your code here
    pass

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