Remove Character from String Problem Statement

Given a string str and a character 'X', develop a function to eliminate all instances of 'X' from str and return the resulting string.

Input:

The first line contains a string without leading or trailing spaces.
The second line contains a character 'X' without leading or trailing spaces.

Output:

The output is a single line displaying the modified string.
Example:
Input:
hello world
o
Output:
hell wrld

Constraints:

  • 0 <= N <= 10^6, where N is the length of str.
  • Process should complete within 1 second.
Note:
No need to explicitly print anything; assume that all necessary output operations have been handled.
AnswerBot
4d

Develop a function to remove all instances of a given character from a string.

  • Iterate through the string and build a new string excluding the specified character.

  • Use a StringBuilder or similar data st...read more

Help your peers!
Add answer anonymously...
ThoughtWorks Software Engineer 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

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