FastPrepPut the Letters of a String in Alphabetical Order
Problems/Put the Letters of a String in Alphabetical Order

Put the Letters of a String in Alphabetical Order

Capital One logoCapital One● EasyFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: An April 2014 Capital One software developer report from Richmond lists a short technical question, to sort a string. The process had a phone screen and a face-to-face interview.

It does not say whether the letters or the words are sorted, or what the alphabet is. Here the string has 1 to 5000 lowercase letters, which are rearranged into alphabetical order with repeats kept. The editorial counts letters instead of using a library sort. These are our choices.

Our version is about 70% the same as the reported question.

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) → String

Examples

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 <= 5000
  • s contains 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
All Capital One interview questionsSee Capital One hiring insights
Saved
class Solution {
    public String sortLetters(String s) {
        // Write your code here.
    }
}
Checking account…