All problems
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
pass3 test cases · run your code against them in the editor