Skip to content

Commit c0e0176

Browse files
authored
format
1 parent c4870ff commit c0e0176

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

count-vowel-strings-in-ranges/index.kt

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,23 @@ package com.github.masx200.leetcode_test.count_vowel_strings_in_ranges
22

33
class Solution {
44
fun vowelStrings(words: Array<String>, queries: Array<IntArray>): IntArray {
5-
6-
75
val prefixs = IntArray(words.size) { 0 }
86

97
words.forEachIndexed { i, s ->
108
if (i == 0) {
11-
129
prefixs[i] = booleanToInt(isVowelString(s))
1310
} else {
1411
prefixs[i] = prefixs[i - 1] + booleanToInt(isVowelString(s))
15-
1612
}
17-
1813
}
1914
return IntArray(queries.size) {
2015
val li = queries[it][0]
2116
val ri = queries[it][1]
2217
if (li == ri) booleanToInt(isVowelString(words[li])) else prefixs[ri] - if (li == 0) 0 else prefixs[li - 1]
2318
}
2419
}
25-
private val vowels = hashSetOf('a', 'e', 'i', 'o', 'u')
20+
private val vowels = hashSetOf('a', 'e', 'i', 'o', 'u')
2621
private fun isVowelString(s: String): Boolean {
27-
2822
return s.isNotEmpty() && vowels.contains(s[0]) && vowels.contains(s.last())
2923
}
3024

0 commit comments

Comments
 (0)