FastPrepFirst Unique Character in a String
Problems/First Unique Character in a String

First Unique Character in a String

Zillow logoZillow● EasyFULLTIMEINTERNOAPHONE SCREENONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Asked at Zillow from about 2013 to 2022, most often in phone screens, and also in an interview at a conference and in other coding rounds. One report had an online test and then phone interviews, and it does not say which round had this question. The reports came from software intern candidates, senior software candidates, and other candidates who gave no level. The task was to find the first character in a string that shows up only once. One senior candidate was also asked to solve it while going through an array of characters only once.

The reports ask for the character itself, but they do not say which characters can appear or what to return when no character is unique. Here the string holds only lowercase letters, the character comes back as a one-letter string, and you return an empty string when there is none. The editorial covers that one-pass follow-up.

Our version is about 85% the same as the reported question.

Given a string s, return the first character of s that appears in s exactly once, as a string of length 1.

"First" means the character with the smallest index among all characters that appear exactly once. If no character of s appears exactly once, return an empty string "".

Function

firstUniqueChar(s: String) → String

Examples

Example 1

s = "aabbcd"return = "c"

'a' and 'b' each appear twice. 'c' and 'd' each appear once, and 'c' comes first.

Example 2

s = "level"return = "v"

'l' and 'e' come before 'v', but each of them appears again later in the string. 'v' at index 2 is the only character that appears once.

Example 3

s = "abcabc"return = ""

Every character appears twice, so no character appears exactly once and the answer is an empty string.

Example 4

s = "z"return = "z"

The only character appears once, so it is the answer.

Constraints

  • 1 <= s.length <= 105
  • s consists only of lowercase English letters.

More Zillow Phone Screen questions

  • Valid ParenthesesPHONE SCREEN · ONSITE INTERVIEW · Seen Jul 2025
  • Build a Hash TableOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Feb 2023
  • Reversible Run-Length EncodingPHONE SCREEN · Seen Nov 2022
  • Cumulative Fibonacci SumOA · PHONE SCREEN · Seen Aug 2021
  • First N Fibonacci NumbersOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Jun 2021
  • Lowest Common Ancestor in a Binary TreePHONE SCREEN · Seen Sep 2019
  • LRU CachePHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2016
  • Blackjack Hand ScorePHONE SCREEN · ONSITE INTERVIEW · Seen Feb 2016
  • FactorialPHONE SCREEN · ONSITE INTERVIEW · Seen Dec 2014
  • Find the Four Missing Numbers in a FileOA · PHONE SCREEN · Seen Feb 2014

Similar questions at other companies

  • Non-Repeating CharacterAutodesk · ONSITE INTERVIEWAutodesk interview questions
  • Container Ledger with TradesFlexport · ONSITE INTERVIEWFlexport interview questions
  • Branch with the Most FilesCapital One · OACapital One interview questions
  • Transaction Fee Calculator — Parts 1–2: Basic Fee Calculation and Conditional Fee RulesStripe · PHONE SCREENStripe interview questions
  • Count User Mentions in Chat MessagesRamp · OARamp 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
  • Count Adjacent Symbol Pairs for BPEAmazon · ONSITE INTERVIEW
  • Total Each Letter's Count in an Encoded StringIBM · OAIBM interview questions
All Zillow interview questionsSee Zillow hiring insights
Saved
class Solution {
    public String firstUniqueChar(String s) {
        // Write your code here.
    }
}
Checking account…