Cool String Check
Updated
Problem statement
A string is cool when every letter that appears in it appears the same number of times. For example, "aabbcc" is cool because a, b and c each appear 2 times. The string "aaabbc" is not cool because a appears 3 times, b appears 2 times and c appears once.
Given a string s, return true if it is cool and false otherwise.
Only the letters that appear in s are compared. A letter that does not appear is ignored. So "ab" is cool, and so is a string with one distinct letter such as "zzzz".
Function
isCoolString(s: String) → booleanExamples
Example 1
s = "aabbcc"return = trueThe letters are a, b and c. Each one appears 2 times, so the string is cool and the answer is true.
Example 2
s = "aaabbc"return = falseThe letter a appears 3 times, b appears 2 times and c appears 1 time. The counts are not all the same, so the answer is false.
Example 3
s = "abba"return = trueThe letter a appears 2 times and b appears 2 times. The order of the letters does not matter, so the answer is true.
Constraints
1 <= s.length <= 100000scontains only lowercase English letters ('a'to'z').
More Bloomberg LP Phone Screen questions
- N-ary Index-Path Encoder and DecoderPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Trapping Rain WaterPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Word SearchOA · PHONE 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
- Add Two Numbers IIPHONE 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
- 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
- Summarize Server Healthcheck LogsNVIDIA · PHONE SCREENNVIDIA interview questions
- Known Words Matching Phone DigitsLinkedIn · PHONE SCREENLinkedIn interview questions