Put the Letters of a String in Alphabetical Order
Updated
Problem statement
Rearrange the letters of s so that they run from a to z, and return the new string. Every letter stays, so a letter that occurs three times occurs three times in the answer.
Function
sortLetters(s: String) → StringExamples
Example 1
s = "coffee"return = "ceeffo"coffee holds one c, one o, two fs and two es. In alphabetical order: ceeffo.
Example 2
s = "zyx"return = "xyz"The letters are reversed from alphabetical order, so the answer reverses them.
Example 3
s = "q"return = "q"A single letter is already in order.
Constraints
1 <= s.length <= 5000scontains only lowercase English letters.
More Capital One Onsite Interview questions
- Digit-Coded Card ValidationONSITE INTERVIEW · Seen Nov 2026
- Sort ColorsONSITE INTERVIEW · Seen Oct 2026
- Virtual Card Transaction ValidatorONSITE INTERVIEW · Seen Oct 2026
- Banking System with Top ActivityONSITE INTERVIEW · Seen Sep 2026
- Transaction Event StoreONSITE INTERVIEW · Seen Jul 2026
- Shortest Path in an Unweighted GraphONSITE INTERVIEW · Seen Jul 2026
- Duplicate Transactions Within 60 SecondsONSITE INTERVIEW · Seen May 2026
- LRU CachePHONE SCREEN · ONSITE INTERVIEW · Seen May 2026
- Cashback TrackerONSITE INTERVIEW · Seen Nov 2025
- Reverse a StringOA · ONSITE INTERVIEW · Seen Oct 2025
Similar questions at other companies
- Count Adjacent Symbol Pairs for BPEAmazon · ONSITE INTERVIEW
- Map and Accumulate Learning QueriesPalantir · ONSITE INTERVIEWPalantir interview questions
- Sort Topic Names by Prefix and NumberPerplexity AI · ONSITE INTERVIEWPerplexity AI interview questions
- Sort Words by LengthMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
- Compress Consecutive Integer RangesDocuSign · ONSITE INTERVIEWDocuSign interview questions
- Sort Sentence WordsInfosys · ONSITE INTERVIEWInfosys interview questions
- Deduplicate Logs: Keep FirstGoogle · ONSITE INTERVIEWGoogle interview questions
- Check AnagramsDeloitte · ONSITE INTERVIEWDeloitte interview questions
- Check AnagramsBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
- Check Anagram Pairs Index by IndexExpedia · ONSITE INTERVIEWExpedia interview questions
Capital One interview experiences
- Capital One Coding OA Questions: 3 Experiences
- Capital One Experienced Engineer Power Day and OA: 6 Experiences
- Capital One New Grad OA Questions: 14 Experiences (Part 2 of 2)
- Capital One TDP Agentic Round (AI Coding): 7 Experiences
- Capital One SWE Power Day, Level Not Reported: 6 Experiences
- Capital One TIP Intern OA and Power Day: 13 Experiences