FastPrepRemove Duplicate Characters
Problems/Remove Duplicate Characters

Remove Duplicate Characters

WhatNot logoWhatNot● EasyFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A Senior Software Engineer report mentions removing duplicates from a string without the detailed rules. Our version is about 65% the same as the reported question. It keeps the first occurrence of each character across the whole string. The order, alphabet, empty case, and limits are set here.

Given a string s, remove repeated occurrences of each character so that every distinct character appears exactly once. Keep its first occurrence, preserving the order in which distinct characters first appear.

Duplicates may occur anywhere, not only next to each other. For example, abbaca becomes abc. Characters are not removed in pairs, and the output is not rearranged alphabetically.

Return the resulting string. An empty input produces an empty string.

Function

removeDuplicateCharacters(s: String) → String

Examples

Example 1

s = "banana"return = "ban"

The first appearances are b, a, n; later copies are removed.

Example 2

s = "cbacdcbc"return = "cbad"

Distinct characters first appear as c, b, a, d.

Example 3

s = ""return = ""

There are no characters to retain.

Constraints

  • 0 <= s.length <= 10000.
  • s contains only lowercase English letters.

More WhatNot Phone Screen questions

  • Merge Sorted Squares of Two ArraysPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Adjacent Pair and Run RemovalPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • User Journey PathsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • User Journey Paths from a Log StreamPHONE SCREEN · Seen Nov 2026
  • Reachable Exits in an Obstacle GridPHONE SCREEN · Seen Oct 2026
  • Palindrome with One DeletionPHONE SCREEN · Seen Oct 2026
  • Search a 2D MatrixPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Attraction Route Without Reusing TrailsPHONE SCREEN · Seen Sep 2026
  • Earliest Car for Each PassengerPHONE SCREEN · Seen Sep 2026
  • Minimum Stores for a Shopping ListPHONE SCREEN · Seen Sep 2026

Similar questions at other companies

  • Transaction Fee Calculator — Parts 1–2: Basic Fee Calculation and Conditional Fee RulesStripe · PHONE SCREENStripe interview questions
  • Detect a Straight FlushTemu · PHONE SCREENTemu interview questions
  • First Letter to Appear TwiceCisco · PHONE SCREENCisco interview questions
  • Halfway Course in a Single TrackCrunchyroll · PHONE SCREENCrunchyroll interview questions
  • Single-Condition Product FilterCrowdstrike · PHONE SCREENCrowdstrike interview questions
  • Summarize Server Healthcheck LogsNVIDIA · PHONE SCREENNVIDIA interview questions
  • Known Words Matching Phone DigitsLinkedIn · PHONE SCREENLinkedIn interview questions
  • First Non-Repeated CharacterDell Technologies · PHONE SCREENDell Technologies interview questions
  • Convert an Entry List to a MapEPAM · PHONE SCREENEPAM interview questions
  • First Non-Repeating CharacterGoldman Sachs · PHONE SCREEN · ONSITE INTERVIEWGoldman Sachs interview questions

Interview reports that mention this question

  • Whatnot interviews · October 2025

WhatNot interview experiences

  • Whatnot OA · 2024
  • Whatnot OA · November 2023
  • Whatnot interviews · November 2023
  • Whatnot interviews · February 2024
  • Whatnot interviews · March 2024
All WhatNot interview questionsSee WhatNot hiring insights
Saved
class Solution {
    public String removeDuplicateCharacters(String s) {
        // write your code here
    }
}
Checking account…