Remove Character from String Task

Given a string str and a character X, your task is to create a function that removes all occurrences of X from the given string.

If the character X is not found in the string, the string remains unchanged.

Input:

The first line contains the input string without leading or trailing spaces.
The second line contains the character X to be removed, without leading or trailing spaces.

Output:

Print the updated string after all occurrences of X have been removed.

Example:

Input:
hello world
l
Output:
heo word

Constraints:

  • 0 <= N <= 10^6, where N is the length of the input string.
  • Time Limit: 1 second

Note:

You do not need to print anything explicitly; it is already handled. Implement the function and return the result.
AnswerBot
4d

Create a function to remove all occurrences of a given character from a string.

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

  • Use string manipulation functions to ...read more

Help your peers!
Add answer anonymously...
Indiamart Intermesh 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