# PROBLEM LINKS:

Practice

Contest

**Author:** Animesh Fatehpuria

**Testers:** Rajat De Sumit Shyamsukha

**Editorialist:** Animesh Fatehpuria

# DIFFICULTY:

CAKEWALK

# PREREQUISITES:

Traversal Through Strings.

# PROBLEM:

Given a String **S** and a substring **X** , remove all occurences of **X** from **S** . Print the resulting String. If the resulting String has length = zero , print "0"(without quotes).

# EXPLANATION:

Python and Java users can simply use the replace() method which replaces all occurrences of a specified substring with another substring. If **S** and **X** are given , all that is needed to do is:

**S=S.replace(X,"");**

If Length is zero Print **0** else Print **S** .

This problem can also be solved by traversing through **S** and checking whether **X** is formed from ith to (i+l)th position where l=length of **X**.

Then We simply exclude the substring **X** if it is present at any part of **S**.

# AUTHOR'S SOLUTION:

Author's solution .

asked
**13 Dec '14, 00:01**

6★animesh_f ♦

883●1●4●22

accept rate:
9%