Skip to content

Commit 570cedc

Browse files
authored
Update README_EN.md
1 parent bd61c0d commit 570cedc

File tree

1 file changed

+6
-14
lines changed
  • solution/1200-1299/1220.Count Vowels Permutation

1 file changed

+6
-14
lines changed

solution/1200-1299/1220.Count Vowels Permutation/README_EN.md

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -215,37 +215,29 @@ class Solution {
215215
}
216216
```
217217

218-
```Java(Optimized with O(n) Time Complexity and O(1) Space)
218+
```java
219219
class Solution {
220-
private final int mod = (int) 1e9 + 7;
221-
222220
public int countVowelPermutation(int n) {
223-
final int MOD = 1000000007;
224-
221+
final int mod = 1000000007;
225222
long countA = 1, countE = 1, countI = 1, countO = 1, countU = 1;
226-
227223
for (int length = 1; length < n; length++) {
228224
// Calculate the next counts for each vowel based on the previous counts
229225
long nextCountA = countE;
230-
long nextCountE = (countA + countI) % MOD;
231-
long nextCountI = (countA + countE + countO + countU) % MOD;
232-
long nextCountO = (countI + countU) % MOD;
226+
long nextCountE = (countA + countI) % mod;
227+
long nextCountI = (countA + countE + countO + countU) % mod;
228+
long nextCountO = (countI + countU) % mod;
233229
long nextCountU = countA;
234-
235230
// Update the counts with the newly calculated values for the next length
236231
countA = nextCountA;
237232
countE = nextCountE;
238233
countI = nextCountI;
239234
countO = nextCountO;
240235
countU = nextCountU;
241236
}
242-
243237
// Calculate the total count of valid strings for length n
244-
long totalCount = (countA + countE + countI + countO + countU) % MOD;
245-
238+
long totalCount = (countA + countE + countI + countO + countU) % mod;
246239
return (int) totalCount;
247240
}
248-
249241
}
250242
```
251243

0 commit comments

Comments
 (0)