Sliding window to solve "longest substring, no repeating chars"
Summary: stay with your implementation.

I don't think a re-usable sliding window fits well to your algorithm.

What are the operations that come to one's mind with both a generic sliding String window and with your algorithm (I'll stay with your terminology of head and tail, although personally I'd name them just the other way round)?


advanceHead() generic op, not used by your algo (see jumpHead())
advanceTail() generic op, used by your algo
jumpHead(int newPos) only specific to your algo
getSubstring() generic op, not used by your algo
findInSubstring(char ch) maybe generic op, not really used by your algo (see below method)
lastOccurrenceBeforeTail(char ch) used by your algo, but I wouldn't expect such a method in a generic sliding window


So, there's hardly any overlap between your algo's sliding window and operations one would expect from a re-usable generic sliding window.

If you'd extract a sliding window from your algorithm, it would be burdened by quite specific methods that no-one else would ever use.

If you were to use a generic sliding window in your algorithm, you'd still have to maintain the character-positions storage and do the head-jumping individually.

One optional refactoring of your code could be to extract a NonRepeatingSlidingWindow with two public methods:


advance() increments the tail, jumps the head if necessary and returns a "finished"-flag
getLength() returns the current size of the sliding window.