FastPrepMaximum String Beauty
Problems/Maximum String Beauty

Maximum String Beauty

Bank of America logoBank of America● EasyINTERNNEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported by several Bank of America candidates, interns and new grads, as one of the coding tasks in a recorded video interview. The task was to give every letter its own value from 1 to 26, with upper and lower case counted as one letter, so that the letters of a text add up to the largest total.

One report also says that characters other than letters do not count. The reports read lines of text and give no limits; here each call gets one string of at most 10,000 characters made of letters, digits, spaces and common punctuation.

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

Given a string s, give each of the 26 English letters a different beauty value from 1 to 26 so that the beauty of s is as large as possible, and return that largest beauty.

The beauty of s is the sum of the beauty values of all its letters. Upper and lower case forms of a letter are the same letter and share one value. Characters that are not letters add nothing.

Function

maxBeauty(s: String) → int

Examples

Example 1

s = "Hello"return = 124

l appears twice and gets 26. h, e and o appear once and get 25, 24 and 23. 2 * 26 + 25 + 24 + 23 = 124.

Example 2

s = "aAbB, ab!"return = 153

Ignoring case, a and b each appear 3 times; the comma, space and ! add nothing. One gets 26 and the other 25: 3 * 26 + 3 * 25 = 153.

Example 3

s = "2024!"return = 0

There are no letters, so the beauty is 0.

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
  • 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
  • Letter Pattern SumOA · Seen Sep 2022

Similar questions at other companies

  • Maximize Palindromic WordsSquarepoint Capital · OASquarepoint Capital interview questions
  • Count User Mentions in Chat MessagesRamp · OARamp interview questions
  • Blood Type Inheritance: Possible Parent GenotypesAbridge · OAAbridge interview questions
  • Count Repeated Request IDs (Data Science OA)McKinsey & Company · OAMcKinsey & Company interview questions
  • Minimum Operations to Reduce a Transaction LedgerVisa · OAVisa interview questions
  • Flat JSON Value DifferencesChubb · OAChubb interview questions
  • Get Search ResultsJP Morgan Chase · OAJP Morgan Chase interview questions
  • Lexicographic Word FrequenciesUpstart · OAUpstart interview questions
  • Email Log Processing, Grouping, and SortingStripe · OAStripe interview questions
  • Most Frequent CharacterMicrosoft · OAMicrosoft 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 maxBeauty(String s) {
        // write your code here
    }
}
Checking account…