Member-only story

Longest Substring with No Repeating Characters Using Python 🐍| Coding Interview | Sliding Window Pattern

Ganesh Prasad
4 min readFeb 5, 2022

--

The strategy used for this problem is similar to the Smallest Subarray with a Given Sum and I have included this problem in our plan because it's simple and works best to realize the pattern of sliding windows.

Longest substring with no repeat characters
No repeat substring

Wow!! 🤯 This problem was asked by many companies including Amazon, Bloomberg, Microsoft, Facebook (meta), Adobe, Google, Apple, Uber, and Goldmann Sachs.

Though I will not discuss the brute force approach, since it is similar to other previous sliding window-based problems I wrote about.

If you are preparing for an upcoming coding interview, you might be interested in the 30 days preparation plan.

Now let’s begin.

Description

We are given a string S, and we have to return the length of the longest substring with unique characters.

Example 1:Input: S = "aabcba"
Output: 3

--

--

Ganesh Prasad
Ganesh Prasad

Written by Ganesh Prasad

Backend Developer at Appscrip | C++ veteran, 💜 Dart

No responses yet