Replace by X (GFG)

 Replace by X 

Given a string and a pattern, Replace all the continuous occurrence of pattern with a single X in the string. For a clear view see the example below.

Input:

The first line of input contains an integer T denoting the number of test cases.
The first line of each test case is string str.
The second line of each test case contains a string s,which is a pattern.

Output:

Print the modified string str.

Constraints:

1 ≤ T ≤ 100
1 ≤ size of str,s ≤ 1000

Example:

Input
2
abababcdefababcdab
ab
geeksforgeeks
geeks

Output
XcdefXcdX
XforX


SOLUTION:

t=int(input())

for i in range (t):

    s=input()

    p=input()

    if p in s:

        h=s.replace(p,"X")

        print(h)



#parakram ek question yeh atlest bata do.....


Wrong Answer. !!!Wrong Answer

Possibly your code doesn't work correctly for multiple test-cases (TCs).

The first test case where your code failed:

Input:
hwllosdhhjhrajatttttteejbarajarajaahsdghjraja raja

Its Correct output is:
hwllosdhhjhXtttttteejbaXahsdghjX

And Your Code's output is:
hwllosdhhjhXtttttteejbaXXahsdghjX

Comments

Popular posts from this blog

Short Notes Of computer Network

Short Note of Data Structure

Implement stack using array