FastPrepWildcard Substring Match
Problems/Wildcard Substring Match

Wildcard Substring Match

Bank of America logoBank of America● MediumNEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Bank of America new grad recorded video interview that also had coding tasks. The task was to check whether a pattern shows up inside a longer string, where a star stands for any run of characters and a backslash in front of a star makes it a plain star.

The report gives no examples or limits. Here, a star can also match nothing, two backslashes stand for one plain backslash, and each string has at most 1000 characters made of lowercase letters, digits, stars and backslashes.

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

Given two strings text and pattern, return true if pattern matches some substring of text, and false otherwise.

The pattern is read from left to right:

  • * matches any run of characters, including an empty run.
  • A backslash makes the next character plain: \* matches one * character, and \\ matches one backslash.
  • Every other character matches only itself.

A substring is a contiguous part of text. Characters in text are always plain, including * and backslashes.

Examples write strings as code literals, so "e\\*1" is the four characters e, \, * and 1.

Function

matchesSubstring(text: String, pattern: String) → boolean

Examples

Example 1

text = "bankofamerica"pattern = "kof*ica"return = true

The substring "kofamerica" matches: "kof" matches itself, * covers "amer", and "ica" matches itself.

Example 2

text = "bankofamerica"pattern = "ame*bank"return = false

"bank" appears only at the start of text, before "ame". No substring starts with "ame" and later has "bank".

Example 3

text = "rate*10"pattern = "e\\*1"return = true

The backslash makes the * a plain star, so the pattern matches only "e*1", which appears in text.

Example 4

text = "rate10"pattern = "e\\*1"return = false

text has no * character, so "e*1" cannot be found. Without the backslash, the pattern "e*1" would match "e1".

Constraints

  • 1 <= text.length <= 1000
  • 1 <= pattern.length <= 1000
  • text and pattern consist of lowercase English letters, digits, * and backslashes.
  • Reading pattern from left to right, each backslash that is not itself escaped is followed by * or another backslash.

More Bank of America Online Assessment questions

  • Return Exact Cash Register ChangeOA · Seen Aug 2026
  • Sum Skipping Multiples of 7OA · 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
  • Letter Pattern SumOA · Seen Sep 2022

Similar questions at other companies

  • Maximum Equal-Bit Pairs in a SubsequenceAmazon · OA
  • Longest Subsequence That Is a SubstringBooking.com · OA
  • Count Digit Replacements with No Equal Adjacent DigitsMicrosoft · OAMicrosoft interview questions
  • Palindrome CounterGoldman Sachs · OAGoldman Sachs interview questions
  • Longest String ChainVisa · OAVisa interview questions
  • Minimum-Cost Digit String DecodingSquadStack.ai · OA
  • Maximum Redundancy After One Segment FlipBloomberg LP · OABloomberg LP interview questions
  • Substrings Without a Target SubsequencePhonePe · OAPhonePe interview questions
  • Minimum Edit-Distance String for Each QueryTarget · OA
  • Longest Subsequence That Is a SubstringWells Fargo · OAWells Fargo 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 boolean matchesSubstring(String text, String pattern) {
        // write your code here
    }
}
Checking account…