Index of the First Non-Repeating Character
Updated
Problem statement
Given a non-empty string s, return the zero-based index of the first character whose total frequency in the string is exactly one.
If no such character exists, return -1. Character comparisons are case-sensitive.
Function
firstNonRepeatingIndex(s: String) → intExamples
Example 1
s = "swiss"return = 1The character s repeats, while w occurs once at index 1.
Example 2
s = "aabbc"return = 4Only c has frequency one, and its index is 4.
Example 3
s = "aabb"return = -1Every character repeats, so there is no qualifying index.
Constraints
1 ≤ s.length ≤ 100000.scontains printable ASCII characters.
More Bloomberg LP Phone Screen questions
- Pascal's TrianglePHONE SCREEN · ONSITE INTERVIEW · Seen Dec 2026
- Valid Triangle NumberPHONE SCREEN · ONSITE INTERVIEW · Seen Dec 2026
- Collatz Conjecture with Shared MemoizationPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Word SearchOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- N-ary Index-Path Encoder and DecoderPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Trapping Rain WaterPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Fewest Coins CombinationPHONE SCREEN · Seen Nov 2026
- Recommend Films from Viewers Who Watched Everything You DidPHONE SCREEN · Seen Nov 2026
- Track New Values in Sorted OrderPHONE SCREEN · Seen Nov 2026
- Design Browser HistoryPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
Similar questions at other companies
- Transaction Fee Calculator — Parts 1–2: Basic Fee Calculation and Conditional Fee RulesStripe · PHONE SCREENStripe interview questions
- Non-Repeating CharacterAutodesk · ONSITE INTERVIEWAutodesk interview questions
- Container Ledger with TradesFlexport · ONSITE INTERVIEWFlexport 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
- Count a User's Actions in an Event LogMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
- Single-Condition Product FilterCrowdstrike · PHONE SCREENCrowdstrike interview questions
- Map and Accumulate Learning QueriesPalantir · ONSITE INTERVIEWPalantir interview questions
Interview reports that mention this question
Bloomberg LP interview experiences
- Bloomberg AI-Assisted Coding Round, All Levels: 14 Experiences
- Bloomberg SWE Intern Interview Questions: 68 Questions
- Bloomberg Interview Questions, Level Not Reported: 65 Questions
- Bloomberg Experienced Design & More: 126 Questions (Part 2 of 2)
- Bloomberg Experienced SWE Interviews: 167 Questions (Part 1 of 2)