FastPrepMerge Strings Alternately
Problems/Merge Strings Alternately

Merge Strings Alternately

Bank of America logoBank of America● EasyNEW GRADONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported by a new grad software engineer from a Bank of America campus hiring drive, in the first live technical interview. The task was to print two strings woven together, one character from each in turn by index, with the leftover part of the longer string at the end.

The report gives no examples or limits. Here, the result is returned instead of printed, and each string has 1 to 1,000 lowercase English letters.

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

Given two strings word1 and word2, return the string built by taking their characters in turn by index: word1[0], word2[0], word1[1], word2[1], and so on.

When one string runs out, add the rest of the other string to the end.

Function

mergeAlternately(word1: String, word2: String) → String

Examples

Example 1

word1 = "abc"word2 = "pq"return = "apbqc"

Take a, p, b, q. word2 is then used up, so the leftover c goes at the end.

Example 2

word1 = "xy"word2 = "mnop"return = "xmynop"

Take x, m, y, n. word1 is used up, so "op" from word2 is added at the end.

Example 3

word1 = "k"word2 = "z"return = "kz"

Both strings have one character, so the result is k then z.

Constraints

  • 1 <= word1.length, word2.length <= 1000
  • word1 and word2 consist of lowercase English letters.

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

  • Longest Spoken PrefixElevenLabs · ONSITE INTERVIEWElevenLabs interview questions
  • Palindrome Check Ignoring SymbolsWalmart · ONSITE INTERVIEWWalmart interview questions
  • Reverse a String Keeping Dashes in PlaceNykaa · ONSITE INTERVIEWNykaa interview questions
  • Reverse Vowels of a StringGoogle · ONSITE INTERVIEWGoogle interview questions
  • Valid Palindrome After NormalizationKotak Mahindra Bank · ONSITE INTERVIEWKotak Mahindra Bank interview questions
  • Count Binary SubstringsDocuSign · ONSITE INTERVIEWDocuSign interview questions
  • Minimum Changes for Palindromic BlocksCitadel · OA · PHONE SCREEN · ONSITE INTERVIEWCitadel interview questions
  • Palindrome Match PercentageApple · ONSITE INTERVIEWApple interview questions
  • Reverse A StringNVIDIA · ONSITE INTERVIEWNVIDIA interview questions
  • Validate a Word AbbreviationSalesforce · ONSITE INTERVIEWSalesforce 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 mergeAlternately(String word1, String word2) {
        // write your code here
    }
}
Checking account…