I kept track of the instances of each character in a map. Added the next char and removed the one n back. Uniqueness testing was simply asking the map how many entries it had in it, if it was n then job done.
Of course, I did manage to fail to pick up on the case where the first n chars in the string are unique, but that's unlikely to be the puzzle input, but it's fixed now.
I don't really worry about optimising the early puzzles too much, all so far run in under 0.002s so I'm still on track to keep within my 1s budget.
I kept track of the instances of each character in a map. Added the next char and removed the one n back. Uniqueness testing was simply asking the map how many entries it had in it, if it was n then job done.
Of course, I did manage to fail to pick up on the case where the first n chars in the string are unique, but that's unlikely to be the puzzle input, but it's fixed now.
I don't really worry about optimising the early puzzles too much, all so far run in under 0.002s so I'm still on track to keep within my 1s budget.