FastPrepLetter Pattern Sum
Problems/Letter Pattern Sum

Letter Pattern Sum

Bank of America logoBank of America● EasyNEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported by a new grad applying for a developer analyst role with Bank of America in Hong Kong, as one of two coding tasks inside a recorded video interview. The task gave a digit string and a letter pattern with a plus sign, and asked for the sum of the two numbers that the pattern marks out.

The report shows one example and no limits. Here, each letter takes the next digit in order, the pattern has one plus sign with letters on both sides, there is one letter per digit, and there are 2 to 18 digits.

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

Given a string of digits digits and a letter pattern pattern that contains one '+', cut digits into two numbers the way the pattern shows and return their sum.

Each letter in pattern stands for the next digit of digits, in order. The letters before '+' take the first digits and form the first number. The letters after '+' take the remaining digits and form the second number. A number may start with zeros and is read as its usual value, so "007" is 7.

Function

letterPatternSum(digits: String, pattern: String) → long

Examples

Example 1

digits = "4821"pattern = "ab+cd"return = 69

Two letters before '+' take "48", and two letters after it take "21". 48 + 21 = 69.

Example 2

digits = "90005"pattern = "a+bcde"return = 14

The first number is 9. The second is "0005", which is 5. 9 + 5 = 14.

Example 3

digits = "2026"pattern = "xyz+w"return = 208

Any letters can be used. Three letters take "202" and one letter takes "6". 202 + 6 = 208.

Constraints

  • 2 <= digits.length <= 18
  • digits consists only of the characters '0' to '9'.
  • pattern consists of lowercase English letters and exactly one '+', which is not the first or last character.
  • The number of letters in pattern equals digits.length.

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

  • Identification Number Check DigitAbridge · OAAbridge interview questions
  • Count Substrings With Identical CharactersVirtu Financial · OAVirtu Financial interview questions
  • Count Multiples of Three with Two SevensHudson River Trading · OAHudson River Trading interview questions
  • Is This Date a Weekend?Salesforce · OASalesforce interview questions
  • Triple-Position Alphabet EncodingArm · OA
  • Closest ColorTwo Sigma · OATwo Sigma interview questions
  • Prime Number From a StringAdobe · OAAdobe interview questions
  • Sum Integer StringsIntuit · OAIntuit interview questions
  • Digit Changes for a Multiple of 9Nutanix · OANutanix interview questions
  • Count Times Using at Most Two DigitsLSEG · OALSEG 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 long letterPatternSum(String digits, String pattern) {
        // write your code here
    }
}
Checking account…