Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions solution/1200-1299/1220.Count Vowels Permutation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,32 @@ class Solution {
}
```

```java
class Solution {
public int countVowelPermutation(int n) {
final int mod = 1000000007;
long countA = 1, countE = 1, countI = 1, countO = 1, countU = 1;
for (int length = 1; length < n; length++) {
// Calculate the next counts for each vowel based on the previous counts
long nextCountA = countE;
long nextCountE = (countA + countI) % mod;
long nextCountI = (countA + countE + countO + countU) % mod;
long nextCountO = (countI + countU) % mod;
long nextCountU = countA;
// Update the counts with the newly calculated values for the next length
countA = nextCountA;
countE = nextCountE;
countI = nextCountI;
countO = nextCountO;
countU = nextCountU;
}
// Calculate the total count of valid strings for length n
long totalCount = (countA + countE + countI + countO + countU) % mod;
return (int) totalCount;
}
}
```

### **C++**

```cpp
Expand Down
26 changes: 26 additions & 0 deletions solution/1200-1299/1220.Count Vowels Permutation/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,32 @@ class Solution {
}
```

```java
class Solution {
public int countVowelPermutation(int n) {
final int mod = 1000000007;
long countA = 1, countE = 1, countI = 1, countO = 1, countU = 1;
for (int length = 1; length < n; length++) {
// Calculate the next counts for each vowel based on the previous counts
long nextCountA = countE;
long nextCountE = (countA + countI) % mod;
long nextCountI = (countA + countE + countO + countU) % mod;
long nextCountO = (countI + countU) % mod;
long nextCountU = countA;
// Update the counts with the newly calculated values for the next length
countA = nextCountA;
countE = nextCountE;
countI = nextCountI;
countO = nextCountO;
countU = nextCountU;
}
// Calculate the total count of valid strings for length n
long totalCount = (countA + countE + countI + countO + countU) % mod;
return (int) totalCount;
}
}
```

### **C++**

```cpp
Expand Down