We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent aded8e1 commit c281a35Copy full SHA for c281a35
src/medium/763. Partition Labels .kt
@@ -15,16 +15,16 @@ Return a list of integers representing the size of these parts.
15
16
class Medium763 : HashTableTopic, TwoPointersTopic, GreedyTopic {
17
18
- fun partitionLabels(S: String): List<Int> {
+ fun partitionLabels(s: String): List<Int> {
19
val last = IntArray(26)
20
- for (i in S.indices) {
21
- last[S[i] - 'a'] = i
+ for (i in s.indices) {
+ last[s[i] - 'a'] = i
22
}
23
var j = 0
24
var anchor = 0
25
- val ans = mutableListOf<Int>()
26
27
- j = maxOf(j, last[S[i] - 'a'])
+ val ans = ArrayList<Int>()
+ j = maxOf(j, last[s[i] - 'a'])
28
if (i == j) {
29
ans.add(i - anchor + 1)
30
anchor = i + 1
0 commit comments