Skip to content

Commit 00efeff

Browse files
Replace word problem not done yet
1 parent a29ba4a commit 00efeff

3 files changed

+24
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"name":"Replace Word","group":"HackerRank - Final Exam | Introduction to C++ For DSA | Batch 05","url":"https://www.hackerrank.com/contests/final-exam-a-introduction-to-c-for-dsa-a-batch-05/challenges/replace-word","interactive":false,"memoryLimit":512,"timeLimit":4000,"tests":[{"id":1719842603006,"input":"2\nrahimisagoodguy good\ncanyoutellmewhereicanfindheriwillbegreatefultoyouifyoutellmetheanswer you\n","output":"rahimisa#guy\ncan#tellmewhereicanfindheriwillbegreatefulto#if#tellmetheanswer\n"}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"ReplaceWord"}},"batch":{"id":"9353048d-f93b-4b8e-83f0-5d8b755c86bd","size":1},"srcPath":"c:\\xampp\\htdocs\\Phitron\\Learning_and_Solving_Problems_Using_Cpp\\Replace_Word.cpp"}

Replace_Word.cpp

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
4+
int main()
5+
{
6+
int t;
7+
cin >> t;
8+
while (t--)
9+
{
10+
string s, x;
11+
cin >> s >> x;
12+
13+
int pos = 0;
14+
while (s.find(x, pos))
15+
{
16+
s.replace(s.find(x, pos), x.length(), "#");
17+
pos++;
18+
}
19+
cout << s << endl;
20+
}
21+
22+
return 0;
23+
}

output.txt

-1
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
Sakib 25

0 commit comments

Comments
 (0)