Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- public:
- int countVowelPermutation(int n) {
- long long mod=int(1e9)+7;
- vector<long long> dp(5, 1), dp1(5);
- //a:0, e:1, i:2, o:3, u:4
- for(int i=1; i<n; i++){
- dp1[0] = (dp[1]+dp[2]+dp[4])%mod;
- dp1[1] = (dp[2]+dp[0])%mod;
- dp1[2] = (dp[1]+dp[3])%mod;
- dp1[3] = (dp[2])%mod;
- dp1[4] = (dp[3]+dp[2])%mod;
- swap(dp, dp1);
- }
- return (dp[0]+dp[1]+dp[2]+dp[3]+dp[4])%mod;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement