Remove character

For a given string(str) and a character X, write a function to remove all the occurrences of X from the given string and return it.

The input string will remain unchanged if the given character(X) doesn't exist in the input string.

Input Format:
The first line of input contains a string without any leading and trailing spaces.

The second line of input contains a character(X) without any leading and trailing spaces.
Output Format:
The only line of output prints the updated string. 
Note:
You are not required to print anything explicitly. It has already been taken care of.
Constraints:
0 <= N <= 10^6
Where N is the length of the input string.

Time Limit: 1 second
CodingNinjas
author
2y

Approach :

1) We create an empty string that will store our final result. We will return it at the end.

2) We iterate from 0 to the length of the string. Say, our loop variable is i. We can then access ...read more

CodingNinjas
author
2y
Iterative Solution
  • We create an empty string that will store our final result. We will return it at the end.
  • We iterate from 0 to the length of the string. Say, our loop variable is i. We can then acces...read more
Help your peers!
Add answer anonymously...
Siemens Software Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions
Get AmbitionBox app

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter