FastPrepWord Pattern II (Round 1, LC 291 :)
Problems/Word Pattern II (Round 1, LC 291 :)

Word Pattern II (Round 1, LC 291 :)

Microsoft logoMicrosoft● MediumNEW GRADONSITE INTERVIEW

Updated Sep 2026

QuestionFunctionExamplesConstraints

Problem statement

  • Round 1: Word Pattern II 🦭
  • Round 2: Implement Queue using Stacks 🦥
  • Round 3: Island Perimeter 🦉

Given a pattern and a string s, return true if s matches the pattern.

A string s matches a pattern if there is some bijective mapping of single characters to non-empty strings such that if each character in pattern is replaced by the string it maps to, then the resulting string is s. A bijective mapping means that no two characters map to the same string, and no character maps to two different strings.

🌷 wallz carries! 🌷

Function

wordPatternMatch(pattern: String, s: String) → boolean

Examples

Example 1

pattern = "abab"s = "redblueredblue"return = true

One possible mapping is as follows:

  • 'a' -> "red"
  • 'b' -> "blue"

Example 2

pattern = "aaaa"s = "asdasdasdasd"return = true

One possible mapping is as follows:

  • 'a' -> "asd"

Example 3

pattern = "aabb"s = "xyzabcxyzabc"return = false

No possible mapping exists that can satisfy the given pattern and string.

Constraints

  • 1 <= pattern.length, s.length <= 20
  • pattern and s consist of only lowercase English letters.

More Microsoft Onsite Interview questions

  • Bad Request AlertsONSITE INTERVIEW · Seen Nov 2026
  • Longest Substring Without Repeating CharactersONSITE INTERVIEW · Seen Nov 2026
  • Valid ParenthesesONSITE INTERVIEW · Seen Nov 2026
  • Count a User's Actions in an Event LogONSITE INTERVIEW · Seen Nov 2026
  • Smallest Batch Size Within a Step LimitONSITE INTERVIEW · Seen Nov 2026
  • Count Subarrays with Equal Even and Odd CountsONSITE INTERVIEW · Seen Nov 2026
  • Minimum Time to Rot All OrangesONSITE INTERVIEW · Seen Nov 2026
  • Coin ChangeONSITE INTERVIEW · Seen Oct 2026
  • Daily USD Totals with Effective-Dated Exchange RatesONSITE INTERVIEW · Seen Oct 2026
  • Number Words to Digits in Any LanguageONSITE INTERVIEW · Seen Oct 2026

Similar questions at other companies

  • All Long Subsequences Are Dictionary WordsGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
  • Generate Palindromic PermutationsMotive · ONSITE INTERVIEWMotive interview questions
  • Word Break IIAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Word Break IIBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Numeric Poker OperationsRippling · PHONE SCREENRippling interview questions
  • Maximum Unique Substring SplitThe Walt Disney Company · PHONE SCREENThe Walt Disney Company interview questions
  • Word Break IIWex · PHONE SCREEN
  • Classify Password StrengthHackerRank · OA · PHONE SCREEN · ONSITE INTERVIEWHackerRank interview questions
  • Highest Bid Campaign MatcherStackAdapt · ONSITE INTERVIEWStackAdapt interview questions
  • Group AnagramsAmazon Web Services · ONSITE INTERVIEWAmazon Web Services interview questions

Microsoft interview experiences

  • Microsoft OA Questions, October 2026: 4 Experiences
  • Microsoft Experienced SWE Phone Screen: 1 Experience
  • Microsoft Explore and Student SWE: 12 Experiences (Part 6 of 6)
  • Microsoft SWE Intern, Early 2025: 41 Experiences (Part 5 of 6)
  • Microsoft SWE Intern, Mid 2025: 42 Experiences (Part 4 of 6)
  • Microsoft SWE Intern, Late 2025: 47 Experiences (Part 3 of 6)
All Microsoft interview questionsSee Microsoft hiring insights
Saved
class Solution {
    public boolean wordPatternMatch(String pattern, String s) {
      // write your code here
    }

}
Checking account…