leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

0790.cpp (367B)


      1 class Solution {
      2   public:
      3     int numTilings(int n) const {
      4         static const int MOD = 1E9 + 7;
      5         static long long dp[1001] = {0, 1, 2, 5};
      6         memset(dp + 4, 0x00, sizeof(dp) - 16);
      7         if (n <= 3) return dp[n];
      8         for (int i = 4; i <= n; i++) {
      9             dp[i] = (2 * dp[i - 1] + dp[i - 3]) % MOD;
     10         }
     11         return dp[n];
     12     }
     13 };