Word Pattern Problem
Word Pattern Problem — ExecCode Easy DSA Practice
Solve the Word Pattern problem on ExecCode. Free online easy DSA practice in Arrays - Basics. Write and run code in Java, C++, Python — no signup required to run.
Problem description
Given a pattern and a string s, find if s follows the same pattern: a bijection between letters and non-empty words. For Word Pattern, focus on the exact input variables, return only the requested value, and preserve the required time complexity for the intended pattern.
Examples
Input pattern = "abba", s = "dog cat cat dog"; Output true. Input pattern = "abba", s = "dog cat cat fish"; Output false
Constraints
1 ≤ pattern.length ≤ 300 s contains lowercase words separated by single spaces
Practice Word Pattern free on ExecCode. Browse DSA problems, topic map, and placement guides.