Three steps problem lcci

(leetcode.cc)[https://leetcode-cn.com/problems/three-steps-problem-lcci/submissions/]

class Solution:
    def waysToStep(self, n: int) -> int:
        if n<=2: return n
        mod = 1000000007
        dp = [0]*(n+1)
        dp[0] = 1
        dp[1] = 1 
        dp[2] = 2

        for i in range(3,n+1):
            dp[i] = (dp[i-1] + dp[i-2] + dp[i-3]) % mod
        return dp[n]