FastPrepAlternating Letter Case
Problems/Alternating Letter Case

Alternating Letter Case

Bank of America logoBank of America● EasyNEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported by four Bank of America candidates, three of them new grads from campus hiring drives, as one of two coding tasks in a recorded video interview. The task was to switch the letters of a string between upper and lower case in turn, beginning with upper case.

Three reports show the rule with a sample: only letters take part, and spaces, digits and symbols stay as they are without breaking the pattern. The fourth report only points to a version that counts every character by its position and begins with lower case; we follow the other three. The reports give no limits. Here, the string has at most 10,000 characters.

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

Given a string s, return a new string in which the letters switch between upper case and lower case, one after another. The first letter becomes upper case, the second lower case, the third upper case, and so on.

Only letters take part. Spaces, digits and punctuation are copied unchanged and do not move the pattern forward, so the next letter after them simply takes the next case in turn. A letter gets its case from its place among the letters, whatever case it had in s.

Function

alternateCase(s: String) → String

Examples

Example 1

s = "Hello World 2"return = "HeLlO wOrLd 2"

The letters in order are H e l l o W o r l d. They become upper, lower, upper, and so on, so W (the sixth letter) becomes lower case. The spaces and the digit 2 stay as they are.

Example 2

s = "x-ray, ok?"return = "X-rAy, Ok?"

The letters x r a y o k become X r A y O k. The hyphen, the comma, the space and the question mark are kept and do not count as letters, so r right after the hyphen is the second letter and becomes lower case.

Example 3

s = "BANK"return = "BaNk"

The input case does not matter: the second and fourth letters become lower case even though they were upper case.

Constraints

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

More Bank of America Online Assessment questions

  • Return Exact Cash Register ChangeOA · Seen Aug 2026
  • Sum Skipping Multiples of 7OA · Seen Nov 2025
  • Wildcard Substring MatchOA · Seen Nov 2025
  • Maximum String BeautyOA · Seen Sep 2024
  • Merge Point of Two Linked ListsOA · Seen Oct 2023
  • Remove Duplicates from a ListOA · Seen Oct 2023
  • Pairs with Target Sum in a Sorted ArrayOA · Seen Oct 2023
  • Count Level-Order Traversals of a TreeOA · Seen Sep 2023
  • Count Set BitsOA · Seen Sep 2023
  • Count Pairs with Sum KOA · Seen Jun 2023

Similar questions at other companies

  • Branch with the Most FilesCapital One · OACapital One interview questions
  • Robot Stops Left or Right (Forward Deployed Engineer)Boston Consulting Group · OABoston Consulting Group interview questions
  • Blood Type Inheritance: Possible Parent GenotypesAbridge · OAAbridge interview questions
  • REST API: Highest International StudentsRippling · OARippling interview questions
  • Rearrange String by Alternating EndsHudson River Trading · OAHudson River Trading interview questions
  • Filter Isolated Interior Signal BitsSEDEMAC · OA
  • Scale Ingredient QuantitiesUpstart · OAUpstart interview questions
  • Telephone Keypad String EncodingEpic · OAEpic interview questions
  • Count Invalid Log GroupsIBM · OAIBM interview questions
  • Count Case-Insensitive TripletsTikTok · OATikTok 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 alternateCase(String s) {
        // write your code here
    }
}
Checking account…