Replace character

Easy
0/40
8 upvotes
Asked in companies
IBMTCSRecur Club

Problem statement

Given an input string S and two characters c1 and c2, you need to replace every occurrence of character c1 with character c2 in the given string.

Detailed explanation ( Input/output format, Notes, Images )
Input Format :
Line 1 : Input String S
Line 2 : Character c1 and c2 (separated by space)
Output Format :
Updated string
Note :
You don't need to output anything. Just implement the given function.
Constraints :

1 <= Length of String S <= 10^6

Sample Input :
abacd
a x
Sample Output :
xbxcd
Approaches (1)
Time Complexity
Space Complexity
Code Solution
(100% EXP penalty)
Replace character
Full screen
Console