Replace Character Problem Statement
Given an input string S
and two characters 'c1' and 'c2', your task is to replace every occurrence of the character 'c1' with the character 'c2' in the given string.
Input:
Line 1: Input String S
Line 2: Character c1 and c2 (separated by space)
Output:
Updated string
Example:
Input:
S = "hello world"
c1 = "l" c2 = "x"
Output:
"hexxo worxd"
Constraints:
1 <= Length of String S <= 10^6

AnswerBot
4mo
Replace every occurrence of a character in a string with another character.
Iterate through the input string and replace 'c1' with 'c2' using string manipulation functions.
Return the updated string as ...read more
Help your peers!
Add answer anonymously...
Accenture Software Developer interview questions & answers
A Software Developer was asked 1w agoQ. Describe the SOLID principles.
A Software Developer was asked 4mo agoQ. What is polymorphism?
A Software Developer was asked 4mo agoQ. What design software do you know?
Popular interview questions of Software Developer
A Software Developer was asked 1w agoQ1. Describe the SOLID principles.
A Software Developer was asked 4mo agoQ2. What design software do you know?
A Software Developer was asked 4mo agoQ3. Define the tree data structure.
Top HR questions asked in Accenture Software Developer
A Software Developer was asked 1w agoQ1. Explain your projects.
A Software Developer was asked 1mo agoQ2. Why do you believe I am required in the company?
A Software Developer was asked 2mo agoQ3. What motivates you to choose a career in the software development field?
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

