Non-Repeating Character
Updated
Problem statement
Some characters of s show up exactly one time in it; call those non-repeating. Return the leftmost non-repeating character, the one at the smallest position in s, as a string that holds just that character.
When s has no non-repeating character, return "".
Function
firstNonRepeatingChar(s: String) → StringExamples
Example 1
s = "stress"return = "t"The letter s is there three times. t, r and e are there once each, and t is the leftmost of those three.
Example 2
s = "pepper"return = "r"p is there three times and e twice. That leaves r, which is there once and sits at the very end.
Example 3
s = "abba"return = ""a and b are both there twice. Nothing is there just once, so "" is returned.
Constraints
1 <= s.length <= 10^5sis made of lowercase English letters,atoz
More Autodesk interview questions
- Remove Trailing ZerosONSITE INTERVIEW · Seen Nov 2026
- Reverse Linked ListONSITE INTERVIEW · Seen Nov 2026
- LRU Cache with TTLONSITE INTERVIEW · Seen Oct 2026
- Deep Merge with a Conflict ResolverONSITE INTERVIEW · Seen Mar 2026
- Diagonal Bounce TraversalOA · Seen Oct 2026
- Interleave Array HalvesOA · Seen Oct 2026
- Latest Arrival to Catch a BusOA · Seen Oct 2026
- Find Top Two TeamsOA · Seen Sep 2026
- In-Memory Database with TTLOA · Seen Mar 2026
Similar questions at other companies
- Container Ledger with TradesFlexport · ONSITE INTERVIEWFlexport interview questions
- Count Adjacent Symbol Pairs for BPEAmazon · ONSITE INTERVIEW
- Count a User's Actions in an Event LogMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
- Map and Accumulate Learning QueriesPalantir · ONSITE INTERVIEWPalantir interview questions
- Filter Pins by Excluded IDsPinterest · ONSITE INTERVIEWPinterest interview questions
- First Non-Repeating CharacterGoldman Sachs · PHONE SCREEN · ONSITE INTERVIEWGoldman Sachs interview questions
- Longest Dictionary Word from Nine LettersGoogle · ONSITE INTERVIEWGoogle interview questions
- Minimum Replacements to Make Two Strings AnagramsBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
- Logger Rate LimiterAmazon Web Services · ONSITE INTERVIEWAmazon Web Services interview questions
- Isomorphic StringsRemitly · ONSITE INTERVIEWRemitly interview questions