I used an idea similar to paint house ii to do this question, but modified it to get total # of ways instead of minimum Cost. I got a runtime of O(nk^2) and it got a TLE. Afterwards, I looked at other's solutions and was dismayed to discover that my idea seemed completely the wrong way to approach this, and if I got asked this in an interview I probably would have completely failed. What should I do? This is my code btw:

```
class Solution(object):
def numWays(self, n, k):
"""
:type n: int
:type k: int
:rtype: int
"""
if n == 0 or k == 0:
return 0
ways = [[0 for i in xrange(n)] for j in xrange(k)]
#Base case
for i in xrange(k):
ways[i][0] = 1
totalWays = 0
for i in xrange(1, n):
for j in xrange(k):
for prevColor in xrange(k):
if prevColor != j:
ways[j][i] += ways[prevColor][i - 1]
if i == n - 1:
totalWays += ways[prevColor][i - 1]
return totalWays
```