FastPrepK-th Non-Repeating Character Index
Problems/K-th Non-Repeating Character Index

K-th Non-Repeating Character Index

Bloomberg LP logoBloomberg LP● EasyNEW GRADPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report names a well-known problem. It points out the empty string, no unique character, and special symbols as cases, and it widens the task to the k-th unique character. We only added that letters are case-sensitive, characters are printable ASCII, and the answer is -1 when nothing matches. Our version is about 97% the same as the reported question.

Given a possibly empty string s and a positive integer k, scan characters from left to right and consider only characters whose total frequency in s is exactly one.

Return the zero-based index of the k-th such character. Return -1 when fewer than k non-repeating characters exist.

Character comparisons are case-sensitive. Every printable ASCII character, including spaces, digits, and symbols, participates normally.

Function

kthNonRepeatingIndex(s: String, k: int) → int

Examples

Example 1

s = "swiss"k = 2return = 2

The non-repeating characters in encounter order are w at index 1 and i at index 2.

Example 2

s = "a!a?b"k = 2return = 3

The unique characters are !, ?, and b. The second appears at index 3.

Example 3

s = ""k = 1return = -1

The empty string contains no character, so it has no first unique character.

Constraints

  • 0 <= s.length <= 100000.
  • 1 <= k <= 100000.
  • s contains printable ASCII characters.

More Bloomberg LP Phone Screen questions

  • 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
  • Mutable Stock Price Top KPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Sparse Vector and Matrix OperationsPHONE SCREEN · Seen Oct 2026

Similar questions at other companies

  • Ransom NoteThe Walt Disney Company · OA · PHONE SCREENThe Walt Disney Company interview questions
  • Apply Operations to Make a String EmptyFlexport · PHONE SCREENFlexport interview questions
  • AI Role: Next-Word Prediction from a Cleaned CorpusApple · PHONE SCREENApple interview questions
  • Subdomain Visit CountsDatadog · PHONE SCREENDatadog interview questions
  • Count Phrases Formed by Anagram ReplacementWells Fargo · OAWells Fargo interview questions
  • Dictionary Words Formable From LettersGoogle · ONSITE INTERVIEWGoogle interview questions
  • Minimum Deletions to Make Every Letter Count EvenMarshall Wace · OAMarshall Wace interview questions
  • Count One-Swap Number PairsCapital One · OACapital One interview questions
  • How Many Sentences?Chubb · OAChubb interview questions
  • Perfect SubstringsVisa · OAVisa interview questions

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)
  • Bloomberg New Grad Coding Questions: 121 Questions (Part 2 of 2)
All Bloomberg LP interview questionsSee Bloomberg LP hiring insights
Saved
class Solution {
    public int kthNonRepeatingIndex(String s, int k) {
        // Write your code here.
    }

}
Checking account…