Remove Occurrences of Character from String
Given a string str
and a character X
, write a function to remove all occurrences of X
from the string.
If the character X
does not exist in the input string, the string should remain unchanged.
Example:
Input:
str = 'hello world'
X = 'o'
Output:
'hell wrld'
Constraints:
0 <= N <= 10^6
, whereN
is the length of the string.- Time Limit: 1 second

AnswerBot
4mo
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...
Hewlett Packard Enterprise Software Developer interview questions & answers
A Software Developer was asked Q. Given a string, return the character counts. For example, input 'aabbbc' should ...read more
A Software Developer was asked Q. Design a classroom management system.
A Software Developer was asked Q. How well can you adapt to changes in technology used for a project? Explain your...read more
Popular interview questions of Software Developer
A Software Developer was asked Q1. Given a string, return the character counts. For example, input 'aabbbc' should ...read more
A Software Developer was asked Q2. Design a classroom management system.
A Software Developer was asked Q3. How well can you adapt to changes in technology used for a project? Explain your...read more
>
Hewlett Packard Enterprise Software Developer Interview 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

