BUG LAB · Sliding window
The window moves backward
Which string makes this longest unique substring calculation overestimate its answer?
Java · intentionally broken snippet
if (last.containsKey(c)) {
left = last.get(c) + 1;
}
last.put(c, right);
best = Math.max(best, right - left + 1);Assume ordinary supporting code and valid inputs unless the question states otherwise.
Choose an answer before revealing the trace. Keys 1 to 3 work too.