add new solutions
This commit is contained in:
parent
ca24d0a56a
commit
0c73608ce5
36 changed files with 791 additions and 0 deletions
18
solutions/24/q2405/solution.go
Normal file
18
solutions/24/q2405/solution.go
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
package q2405
|
||||
|
||||
func partitionString(s string) int {
|
||||
var seen int32
|
||||
|
||||
partitions := 1
|
||||
for i := range len(s) {
|
||||
offset := s[i] - 'a'
|
||||
if seen|1<<offset == seen {
|
||||
partitions += 1
|
||||
seen = 0
|
||||
}
|
||||
seen |= 1 << offset
|
||||
}
|
||||
return partitions
|
||||
}
|
||||
|
||||
var _ = partitionString
|
||||
Loading…
Add table
Add a link
Reference in a new issue