Skip to content

Commit db34c3b

Browse files
committed
add 2405 ts solution
1 parent 44e2079 commit db34c3b

File tree

1 file changed

+13
-0
lines changed
  • Problems/20-Optimal-Partition-of-String

1 file changed

+13
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
function partitionString(s: string): number {
2+
let arr: string[] = [];
3+
let count = 0;
4+
for(let i = 0; i < s.length; i++) {
5+
if(arr.indexOf(s[i])>= 0) {
6+
count ++;
7+
arr = [];
8+
}
9+
arr.push(s[i]);
10+
}
11+
return count+1;
12+
13+
};

0 commit comments

Comments
 (0)