Skip to content

Commit

Permalink
Update and rename 2320.Count-Number-of-Ways-to-Place-Houses.cpp to 23…
Browse files Browse the repository at this point in the history
…20.Count-Number-of-Ways-to-Place-Houses_v1.cpp
  • Loading branch information
wisdompeak authored Jun 27, 2022
1 parent 8f62433 commit 89cbb34
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
using LL = long long;
LL M = 1e9+7;
class Solution {
LL dp[10001][2];
LL dp[10001][2];
// dp[i][0]: the # of plans so that there is no building at the i-th plot
// dp[i][1]: the # of plans so that there is a building at the i-th plot
public:
int countHousePlacements(int n)
{
dp[1][0] = 1;
dp[1][1] = 1;
dp[0][0] = 1;
dp[0][1] = 0;

for (int i=2; i<=n; i++)
for (int i=1; i<=n; i++)
{
dp[i][0] = (dp[i-1][0] + dp[i-1][1])%M;
dp[i][1] = dp[i-1][0];
Expand Down

0 comments on commit 89cbb34

Please sign in to comment.