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
Please log in to access the Submissions tab, where you can review your progress and explore code submissions from other participants.
Please log in to access the Solution tab and view detailed answers and explanations.
Please log in to access the Discussion tab and join conversations with other participants.
Access Restricted: Please Login to access the code editor and test cases.