FastPrepDuplicate Letters in a String
Problems/Duplicate Letters in a String

Duplicate Letters in a String

Bank of America logoBank of America● EasyNEW GRADONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported by a new grad candidate from a December 2020 campus drive for a full-time Senior Tech Associate role at Bank of America. In the second of three rounds, the first technical interview, the coding task was to print the letters that occur more than once in a string.

The report links a version of this task that also prints how many times each repeated character appears. Here, the string has up to 10,000 lowercase letters, and you return only the repeated letters, once each, in the order of their first appearance.

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

Given a string s of lowercase English letters, find every letter that appears in s more than once.

Return these letters as one string, with each repeated letter written once, in the order in which the letters first appear in s. If no letter appears more than once, return an empty string.

Function

duplicateLetters(s: String) → String

Examples

Example 1

s = "letterpress"return = "etrs"

e appears 3 times, t, r and s twice each, and l and p once. The repeated letters first appear at indexes 1 (e), 2 (t), 5 (r) and 9 (s), so the answer is "etrs".

Example 2

s = "cabbage"return = "ab"

a and b both appear twice. a first appears at index 1 and b at index 2, so a comes first, even though the second b comes before the second a.

Example 3

s = "quiz"return = ""

Every letter appears once, so the answer is the empty string.

Constraints

  • 1 <= s.length <= 10^4
  • s consists of lowercase English letters only.

More Bank of America Onsite Interview questions

  • Centered Star PyramidONSITE INTERVIEW · Seen Nov 2025
  • Employees Without a ManagerONSITE INTERVIEW · Seen Nov 2025
  • Longest Substring Without Repeating CharactersONSITE INTERVIEW · Seen Nov 2025
  • N-th Fibonacci NumberONSITE INTERVIEW · Seen Nov 2025
  • Reverse Each Word in a SentenceONSITE INTERVIEW · Seen Nov 2025
  • Second Highest SalaryONSITE INTERVIEW · Seen Nov 2025
  • Three Numbers That Add Up to a TargetONSITE INTERVIEW · Seen Apr 2025
  • Duplicate RowsONSITE INTERVIEW · Seen Oct 2023
  • Factorial of a NumberONSITE INTERVIEW · Seen Oct 2023
  • Palindrome String CheckONSITE INTERVIEW · Seen Sep 2023

Similar questions at other companies

  • Count Adjacent Symbol Pairs for BPEAmazon · ONSITE INTERVIEW
  • Count a User's Actions in an Event LogMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Map and Accumulate Learning QueriesPalantir · ONSITE INTERVIEWPalantir interview questions
  • Filter Pins by Excluded IDsPinterest · ONSITE INTERVIEWPinterest interview questions
  • First Non-Repeating CharacterGoldman Sachs · PHONE SCREEN · ONSITE INTERVIEWGoldman Sachs interview questions
  • Longest Dictionary Word from Nine LettersGoogle · ONSITE INTERVIEWGoogle interview questions
  • Minimum Replacements to Make Two Strings AnagramsBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Logger Rate LimiterAmazon Web Services · ONSITE INTERVIEWAmazon Web Services interview questions
  • Isomorphic StringsRemitly · ONSITE INTERVIEWRemitly interview questions
  • Check AnagramsDeloitte · ONSITE INTERVIEWDeloitte interview questions

Bank of America interview experiences

  • Bank of America interviews · December 2025
  • Bank of America OA · December 2025
  • Bank of America interviews · September 2026
  • Bank of America OA · September 2026
All Bank of America interview questionsSee Bank of America hiring insights
Saved
class Solution {
    public String duplicateLetters(String s) {
        // write your code here
    }
}
Checking account…