You are not logged in. Please login at www.codechef.com to post your questions!

×

CDQU4 - Editorial

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 .

This question is marked "community wiki".

asked 13 Dec '14, 00:01

animesh_f's gravatar image

6★animesh_f ♦
8831422
accept rate: 9%

edited 18 Apr '17, 22:21

admin's gravatar image

0★admin ♦♦
19.8k350498541

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×15,683
×1,652
×349
×12

question asked: 13 Dec '14, 00:01

question was seen: 892 times

last updated: 04 Dec '17, 11:56