Reported July 2026
Ripplingsliding window

Shortest Substring

Reported by candidates from Rippling's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Rippling OA. Under 2s to a working solution.
Founder's read

The whole solution lives in a 26-slot count array, and that's the part people miss under the clock. Rippling reported this Shortest Substring question in July 2026. You delete one contiguous chunk from a lowercase string so what's left has no repeated letters, and you return the shortest chunk that works. It's a two-pointer sliding window in disguise. The pattern is simple once you see it, but the prefix plus suffix framing trips people up. If your brain goes blank mid-assessment, StealthCoder runs invisibly on your desktop and hands you the working approach in real time. Read the trick below first so you probably won't need it.

The problem

Determine the length of the shortest contiguous substring that can be deleted from a string s so that the remaining string contains only distinct characters.
After deleting a substring, join the part before it with the part after it. If s already contains only distinct characters, return 0.

Function
findShortestSubstring(s: String) → int

Examples
Example 1
s = "abcbbck"
return = 3
Deleting any one of three length-3 choices can leave abck, whose characters are all distinct. No shorter deletion works.
Example 2
s = "xabbcacpqr"
return = 3
Delete bca to obtain xabcpqr.

Constraints
1 <= s.length() <= 10^5
s contains only lowercase English letters.

Reported by candidates. Source: FastPrep

Pattern and pitfall

Flip the question. The kept string is a prefix plus a suffix, and together they must have all distinct letters. Only 26 letters exist, so the kept part never exceeds 26 characters. Keep a count array. Grow the prefix one character at a time while it stays distinct. For each prefix length i, pull the suffix start j leftward as far as the suffix stays distinct and doesn't reuse a letter from the prefix. The deletion length is j minus i. Track the minimum. Use deleting the whole string as the baseline, and return 0 up front if s is already distinct. Common pitfall: brute forcing every substring, which is quadratic or worse and dies at 10^5. Another is forgetting the empty prefix case, where you only delete from the front. If you freeze during the live OA, StealthCoder is the hedge that surfaces this two-pointer setup without the proctor seeing it.

Drill it cold or hedge it with StealthCoder. Either way, don't walk into the OA hoping you remember the trick.

If this hits your live OA

You can drill Shortest Substring cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Made for the candidate who got the OA invite this morning and has 72 hours, not six months.

Get StealthCoder

Related leaked OAs

⏵ The honest play

You've seen the question. Make sure you actually pass Rippling's OA.

Rippling reuses patterns across OAs. Made for the candidate who got the OA invite this morning and has 72 hours, not six months. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Shortest Substring FAQ

How hard is the Rippling Shortest Substring question really?+

Medium. The code is short, but the insight is not obvious. You have to stop thinking about the deleted piece and think about the kept prefix and suffix. Once you frame it that way, it's a linear two-pointer pass with a small count array. Most failures come from brute force timing out.

What's the trick to solving it fast?+

Only 26 lowercase letters exist, so the distinct prefix can't be longer than 26. For each valid prefix, find the smallest suffix start that keeps everything distinct and doesn't collide with the prefix. As the prefix grows, that suffix start only moves right. That monotonic movement gives you O(n).

Which edge cases should I test before submitting?+

Test a string that's already distinct, which must return 0. Test a single character. Test a string where the best deletion starts at index 0, and one where it ends at the last index. Also test all the same letter, like aaaa, where you keep one character and delete the rest, so the answer is n minus 1.

Is the sliding window or two-pointer pattern still asked in 2026 OAs?+

Yes. Rippling reported this one in July 2026, and window and two-pointer questions keep showing up because they separate people who spot the monotonic structure from people who brute force. Expect a string or array input with a constraint around 10^5 that rules out quadratic solutions.

How do I prepare for this in 48 hours?+

Write this solution from scratch twice with a count array. Then do two or three similar problems where you remove or shrink a segment while keeping a validity condition. Focus on stating the invariant out loud: what the prefix holds, what the suffix holds, and why the pointer never moves backward.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Rippling.

OA at Rippling?
Invisible during screen share
Get it