Beautiful Substrings

Limits 1s, 512 MB

Given a binary string T (consisting of 0 and 1) of length exactly 26, which indicates a frequency constraints of first 26 lowercase alphabets. T[i] = ‘1’ indicates i’th alphabet can occur at most once and T[i] = ‘0’ indicates i’th alphabet can occur any number of times. String T is 1 indexed and Alphabets are numbered from 1 to 26. 1st alphabet is ‘a’, 2nd alphabet is ‘b’ …….. and 26th alphabet is ‘z’.


This is a companion discussion topic for the original entry at https://toph.co/p/beautiful-substrings