Remove Every Occurrence of a Character
Updated
Problem statement
Remove every occurrence of character from s, preserving the order of all remaining characters. Return the resulting string.
The character parameter contains exactly one character. Matching is case-sensitive. If it does not occur, return the string unchanged; an empty string remains empty.
Function
removeCharacter(s: String, character: String) → StringExamples
Example 1
s = "banana"character = "a"return = "bnn"Removing the three a characters leaves bnn.
Example 2
s = "Apple"character = "a"return = "Apple"Lowercase a does not match uppercase A, so the string is unchanged.
Constraints
0 <= s.length <= 50000.character.length == 1.- Both inputs contain printable ASCII characters with codes
32through126.
More Expedia Onsite Interview questions
- Scramble StringONSITE INTERVIEW · Seen Sep 2026
- Smallest Sufficient TeamONSITE INTERVIEW · Seen Sep 2026
- Check Anagram Pairs Index by IndexONSITE INTERVIEW · Seen Oct 2025
- Fresh Oranges Left After Rotting StopsONSITE INTERVIEW · Seen Oct 2025
- Longest Increasing SubsequenceONSITE INTERVIEW · Seen Oct 2025
- Lowest Common Ancestor with Repeated and Missing ValuesONSITE INTERVIEW · Seen Oct 2025
- Shortest Substring with Exactly K OnesONSITE INTERVIEW · Seen Oct 2025
- Middle Element of a Linked ListONSITE INTERVIEW · Seen Nov 2024
- Minimum in a Rotated Sorted ArrayONSITE INTERVIEW · Seen Sep 2024
- Mirror Image Binary TreesONSITE INTERVIEW · Seen Sep 2024
Similar questions at other companies
- Longest Common PrefixKotak Mahindra Bank · PHONE SCREEN · ONSITE INTERVIEWKotak Mahindra Bank interview questions
- Valid ParenthesesMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
- Count Adjacent Symbol Pairs for BPEAmazon · ONSITE INTERVIEW
- Longest Spoken PrefixElevenLabs · ONSITE INTERVIEWElevenLabs interview questions
- Palindrome Check Ignoring SymbolsWalmart · ONSITE INTERVIEWWalmart interview questions
- Reverse a String Keeping Dashes in PlaceNykaa · ONSITE INTERVIEWNykaa interview questions
- Implement tail -nConfluent · PHONE SCREEN · ONSITE INTERVIEWConfluent interview questions
- Valid ParenthesesEPAM · ONSITE INTERVIEWEPAM interview questions
- Map and Accumulate Learning QueriesPalantir · ONSITE INTERVIEWPalantir interview questions
- Bounded Word Guess SolverAtlassian · ONSITE INTERVIEWAtlassian interview questions
Interview reports that mention this question
Expedia interview experiences
- Expedia Intern Final Round in 2021: 28 Experiences (Part 4 of 6)
- Expedia Intern Finals Before 2020: 14 Experiences (Part 6 of 6)
- Expedia Intern Final Round in 2020: 24 Experiences (Part 5 of 6)
- Expedia Intern Final Round in 2022: 15 Experiences (Part 3 of 6)
- Expedia Intern Final Round in 2023: 17 Experiences (Part 2 of 6)