FastPrepDo the Words Follow the Letter Pattern?
Problems/Do the Words Follow the Letter Pattern?

Do the Words Follow the Letter Pattern?

Capital One logoCapital One● EasyINTERNFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Four Capital One reports from 2018 and 2019 ask whether a list of words lines up with a pattern. Equal letters must always pair with equal words, and different letters with different words. Three come from intern final-round interviews and one from a software engineer onsite.

Two give the pattern as its own list of letters, as here. The other two pair a pattern string with a sentence. In this version both inputs are arrays of the same length, each pattern entry is one lowercase letter, and the lists hold up to 5000 entries. These are our choices.

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

words and pattern have the same length, and pattern[i] is a single lowercase letter. Position i pairs the word words[i] with the letter pattern[i].

Return true if the pairs are consistent in both directions: every copy of a word is paired with the same letter, and every copy of a letter is paired with the same word. Otherwise return false.

Function

isPattern(words: String[], pattern: String[]) → boolean

Examples

Example 1

words = ["mint","sage","mint","plum"]pattern = ["x","y","x","z"]return = true

mint always sits with x, sage with y and plum with z. Every word has one letter and every letter one word, so the answer is true.

Example 2

words = ["sun","sun","moon"]pattern = ["p","q","r"]return = false

Each letter has only one word, but sun sits with p first and with q next. One word cannot stand for two letters, so the answer is false.

Example 3

words = ["oak","elm","ash","elm"]pattern = ["r","s","r","s"]return = false

The letters look fine on their own, but r is paired with oak and later with ash. One letter cannot stand for two different words, so the answer is false.

Constraints

  • 1 <= words.length == pattern.length <= 5000
  • 1 <= words[i].length <= 10, and words use only lowercase English letters.
  • Each pattern[i] is one lowercase English letter.

More Capital One Onsite Interview questions

  • Digit-Coded Card ValidationONSITE INTERVIEW · Seen Nov 2026
  • Sort ColorsONSITE INTERVIEW · Seen Oct 2026
  • Virtual Card Transaction ValidatorONSITE INTERVIEW · Seen Oct 2026
  • Banking System with Top ActivityONSITE INTERVIEW · Seen Sep 2026
  • Transaction Event StoreONSITE INTERVIEW · Seen Jul 2026
  • Shortest Path in an Unweighted GraphONSITE INTERVIEW · Seen Jul 2026
  • Duplicate Transactions Within 60 SecondsONSITE INTERVIEW · Seen May 2026
  • LRU CachePHONE SCREEN · ONSITE INTERVIEW · Seen May 2026
  • Cashback TrackerONSITE INTERVIEW · Seen Nov 2025
  • Reverse a StringOA · ONSITE INTERVIEW · Seen Oct 2025

Similar questions at other companies

  • Count Adjacent Symbol Pairs for BPEAmazon · ONSITE INTERVIEW
  • Count a User's Actions in an Event LogMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Map and Accumulate Learning QueriesPalantir · ONSITE INTERVIEWPalantir interview questions
  • Filter Pins by Excluded IDsPinterest · ONSITE INTERVIEWPinterest interview questions
  • First Non-Repeating CharacterGoldman Sachs · PHONE SCREEN · ONSITE INTERVIEWGoldman Sachs interview questions
  • Longest Dictionary Word from Nine LettersGoogle · ONSITE INTERVIEWGoogle interview questions
  • Minimum Replacements to Make Two Strings AnagramsBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Logger Rate LimiterAmazon Web Services · ONSITE INTERVIEWAmazon Web Services interview questions
  • Isomorphic StringsRemitly · ONSITE INTERVIEWRemitly interview questions
  • Check AnagramsDeloitte · ONSITE INTERVIEWDeloitte interview questions

Capital One interview experiences

  • Capital One Coding OA Questions: 3 Experiences
  • Capital One Experienced Engineer Power Day and OA: 6 Experiences
  • Capital One New Grad OA Questions: 14 Experiences (Part 2 of 2)
  • Capital One TDP Agentic Round (AI Coding): 7 Experiences
  • Capital One SWE Power Day, Level Not Reported: 6 Experiences
  • Capital One TIP Intern OA and Power Day: 13 Experiences
All Capital One interview questionsSee Capital One hiring insights
Saved
class Solution {
    public boolean isPattern(String[] words, String[] pattern) {
        // Write your code here.
    }
}
Checking account…