Help needed in this String problem

Revision en1, by pkay_24, 2020-07-31 13:09:24

Hello Community !!

So this question appeared in one of the interviews I had given.

Given a String s comprising of digits from 0-9. You need to count number of substrings such that each character present in that substring occurs exactly K times.

constraints: N = size of given string 1 <= N <= 10^5 1 <= K <= N

tc: s="1102021222" K=2 Ans=6

6 substrings are s[0:1]="11" , s[0:5]="110202" , s[1:6]="102021" , s[2:5]="0202" , s[7:8]="22" , s[8:9]="22"

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English pkay_24 2020-07-31 13:09:24 535 Initial revision (published)