
Asked in Accenture
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...
Top Software Developer Interview Questions Asked at Accenture
Q. Describe the SOLID principles.
Q. What is the purpose of if __name__ == "__main__"?
Q. What is Hypertext Markup Language (HTML)?
Interview Questions Asked to Software Developer at Other Companies
Top Skill-Based Questions for Accenture Software Developer
Algorithms Interview Questions and Answers
250 Questions
Data Structures Interview Questions and Answers
250 Questions
Web Development Interview Questions and Answers
250 Questions
Java Interview Questions and Answers
250 Questions
SQL Interview Questions and Answers
250 Questions
Software Development Interview Questions and Answers
250 Questions
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

