Analysis:
Complicated than the
Paint House
since the number of color is not certain. Therefore, we have to store the minIdx, minVal and second small value in case that the minimum value is the same in the last level
Time Complexity:
- O(nk)
Space Complexity:
- O(nk)
Code
1 | class Solution: |