Problem Submissions Solution

Smallest window of 0, 1 and 2

Difficulty: Easy

Acceptance: %

Points: 20.00

Given a string S consisting of the characters 0, 1 and 2. Your task is to find the length of the smallest substring of string S that contains all the three characters 0, 1 and 2. If no such substring exists, then return -1.

Topics

Companies

Articles

Examples:

NA

Constraints:
  • 1 = length( S ) = 10^5
  • All the characters of String S lies in the set {'0', '1', '2'}
Companies:
Paytm
Topics:
String
Locked Content
Access Restricted: Please Login to access the code editor and test cases.