Problem · String
Remove Duplicate Characters
Learn this problemProblem 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.
The source shared the rule but did not include this exact sample. FastPrep added this small example so the behavior can be checked directly.