FastPrepRemove Duplicate Characters
Problems/Remove Duplicate Characters

Remove Duplicate Characters

NatWest Group logoNatWest Group● EasyOA

Updated Nov 2026

QuestionFunctionExamples

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) → String

Examples

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

  • Sum Elements at Even IndicesOA · Seen Jul 2026

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
See NatWest Group hiring insights
Saved
class Solution {
    public String removeDuplicateCharacters(String s) {
      // write your code here
    }
}
Checking account…