Take FREE!! Online AMCAT Mock Test to Crack Wipro NLTH, Capgemini, etc.
Get Off-Campus Placement Jobs Info !!!
Practice Given Here Wipro NLTH Practice Q&A

Deleting Sub-strings

Home > Programs > Strings

378 / 59

Deleting Sub-strings

There are two strings, s, and t.


Perform two operationss with the string s:
1. Working from left-to-right delete each occurrence of t in s until there are no more occurrences of t. Count each deletion.
2. working from right-to-left delete each occurrence of t in s until there are no more occurrences of t. Count each deletion.


When that is done, return the greater of the two counts; deletion left-to-right or deletions right-to-left.

Example
s = 'bcbbc'
t = 'b'

From left to right:
Remove th first occurrence t = 'b' from"

Answer:


Asked In :: SAP Labs HackerRank

Post Your Answer Here: