Peeush Agarwal > Engineer. Learner. Builder.

I am a Machine Learning Engineer passionate about creating practical AI solutions using Machine Learning, NLP, Computer Vision, and Azure technologies. This space is where I document my projects, experiments, and insights as I grow in the world of data science.

View on GitHub

Word Pattern

Problem Statement

Given a pattern and a string s, determine if s follows the same pattern.

A string s follows a pattern if there is a bijection between each letter in the pattern and a non-empty word in s. This means:

Examples

Example 1

Example 2

Example 3

Constraints

Code Template

class Solution:
    def wordPattern(self, pattern: str, s: str) -> bool:
        # Your code here
        pass

Solutions

Back to Problem List Back to Categories