Shortest Path With At Most K Consecutive Identical Characters

Solution Code

Time Complexity

O(nk + mk log(mk)

Space Complexity

O(nk + mk)