Skip to content

Commit

Permalink
�Solution to today's problem
Browse files Browse the repository at this point in the history
  • Loading branch information
spannm committed Oct 30, 2023
1 parent a773ab1 commit c525bff
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.github.spannm.leetcode.lc1.lc1200;

import com.github.spannm.leetcode.LeetcodeProblem;

/**
* <a href="https://leetcode.com/problems/count-vowels-permutation/">1220. Count Vowels Permutation</a>.
*/
public class Problem1220 extends LeetcodeProblem {

public int countVowelPermutation(int _n) {
int mod = 1000_000_007;
long ca = 1;
long ce = 1;
long ci = 1;
long co = 1;
long cu = 1;
long a;
long e;
long i;
long o;
long u;

while (--_n > 0) {
a = (ce + ci + cu) % mod;
e = (ca + ci) % mod;
i = (ce + co) % mod;
o = ci;
u = (ci + co) % mod;

ca = a;
ce = e;
ci = i;
co = o;
cu = u;
}

return (int) ((ca + ce + ci + co + cu) % mod);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.github.spannm.leetcode.lc1.lc1200;

import com.github.spannm.leetcode.LeetcodeBaseTest;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;

class Problem1220Test extends LeetcodeBaseTest {

@ParameterizedTest(name = "[{index}] {0} --> {1}")
@CsvSource(delimiter = ';', value = {
"1; 5",
"2; 10",
"5; 68"
})
void test(
int _n,
int _expectedResult) {

assertEquals(_expectedResult, new Problem1220().countVowelPermutation(_n));
}

}

0 comments on commit c525bff

Please sign in to comment.