FastPrepLongest Substring Without Repeating Characters
Problems/Longest Substring Without Repeating Characters

Longest Substring Without Repeating Characters

Bank of America logoBank of America● MediumNEW GRADONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported by a new grad software engineering apprentice from a Bank of America campus hiring drive, in the second live technical interview. The candidate was asked for the length of the longest stretch of a string where no character shows up twice, then wrote the code and talked through the approach.

The report gives no examples or limits. Here, the string has at most 50,000 characters, made of English letters, digits, spaces and a few punctuation marks.

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

Given a string s, return the length of the longest substring of s in which no character appears more than once.

A substring is a run of characters that sit next to each other in s. Upper and lower case letters are different characters, and a space is a character too.

Function

lengthOfLongestSubstring(s: String) → int

Examples

Example 1

s = "tree house"return = 6

The substring " house" (a space followed by house) has 6 different characters. Any substring of length 7 repeats a character: for example "e house" has e twice.

Example 2

s = "noon"return = 2

"no" and "on" both have length 2. Every longer substring has two os or two ns.

Example 3

s = "zzzz"return = 1

Every substring longer than one character has two zs, so the answer is 1.

Constraints

  • 0 <= s.length <= 5 * 10^4
  • s consists of English letters, digits, spaces and the characters . , ! ? -

More Bank of America Onsite Interview questions

  • Centered Star PyramidONSITE INTERVIEW · Seen Nov 2025
  • Employees Without a ManagerONSITE 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
  • Second Largest Element in an ArrayONSITE INTERVIEW · Seen Jun 2023

Similar questions at other companies

  • Longest Substring Without Repeating CharactersOracle · ONSITE INTERVIEWOracle interview questions
  • Longest Substring Without Repeating CharactersSalesforce · ONSITE INTERVIEWSalesforce interview questions
  • Longest Substring Without Repeating CharactersMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Longest Substring Without Repeating CharactersGoogle · ONSITE INTERVIEWGoogle interview questions
  • Longest Substring Without Repeating CharactersAmazon · ONSITE INTERVIEW
  • Longest Substring Without Repeating CharactersInfosys · ONSITE INTERVIEWInfosys interview questions
  • Longest Substring Without Repeating CharactersOmnissa · ONSITE INTERVIEWOmnissa interview questions
  • Longest Substring Without Repeating CharactersBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Longest Substring with At Most K Distinct CharactersGoldman Sachs · ONSITE INTERVIEWGoldman Sachs interview questions
  • Sliding-Window Rate LimiterStripe · PHONE SCREEN · ONSITE INTERVIEWStripe 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 int lengthOfLongestSubstring(String s) {
        // write your code here
    }
}
Checking account…