Remove Duplicate Characters
Updated
Problem statement
You are given a string s. Remove duplicate characters while preserving the order of their first occurrence, and return the resulting string.
Function
removeDuplicateCharacters(s: String) → StringExamples
Example 1
s = "banana"return = "ban"The first occurrences are b, a, and n. Later repeated characters are skipped.
More NatWest Group Online Assessment questions
Similar questions at other companies
- Branch with the Most FilesCapital One · OACapital One interview questions
- Count User Mentions in Chat MessagesRamp · OARamp interview questions
- First Non-Repeating CharacterAmazon · OA · ONSITE INTERVIEW
- Total Each Letter's Count in an Encoded StringIBM · OAIBM interview questions
- Find Words That Can Be Formed by CharactersTabaPay · OA
- Blood Type Inheritance: Possible Parent GenotypesAbridge · OAAbridge interview questions
- Count Palindrome Addition ChoicesThe D.E. Shaw Group · OAThe D.E. Shaw Group interview questions
- Count Palindrome Addition ChoicesHudson River Trading · OAHudson River Trading interview questions
- Count Phrases Formed by Anagram ReplacementWells Fargo · OAWells Fargo interview questions
- Count Repeated Request IDs (Data Science OA)McKinsey & Company · OAMcKinsey & Company interview questions