Skip to content

Commit

Permalink
day 320: simplify some conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
vaskoz committed Jul 10, 2019
1 parent 7b67c71 commit 8cf5a8f
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions day320/problem.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,11 @@ func SmallestWindowEveryDistinctLength(str string) int {
for end, r := range str {
distinct[r]++
if len(distinct) == distinctCount {
for len(distinct) == distinctCount {
toRemove := rune(str[begin])
if distinct[toRemove] > 1 {
distinct[toRemove]--
begin++
} else {
break
}
for toRemove := rune(str[begin]); distinct[toRemove] > 1; toRemove = rune(str[begin]) {
distinct[toRemove]--
begin++
}
length := end - begin + 1
if length < smallest {
if length := end - begin + 1; length < smallest {
smallest = length
}
}
Expand Down

0 comments on commit 8cf5a8f

Please sign in to comment.