We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
sliding through string looking using index and counting occurences + comments for debug
a=stringb=sub_stringcounter=0slider=0whileslider<=len(a):#print(f"looking for substring {b} in string {a} starting from position {slider}")ifa.find(b,slider)>-1:#print (f"found substring {b} at position {a.find(b,slider)}")slider=a.find(b,slider)counter+=1slider+=1returncounter
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Find a string
You are viewing a single comment's thread. Return to all comments →
sliding through string looking using index and counting occurences + comments for debug