Sobes.tech
Junior — Middle+

Checking the sequence of strings for compliance with the given pattern

livecode

Task condition

Given two input parameters: a string pattern containing only lowercase Latin letters, and an array of strings s. The task is to implement the function matchPattern, which checks whether a one-to-one correspondence can be established between the characters of pattern and the elements of array s. In other words, each character of pattern should correspond to exactly one string from s, and each string from s should correspond to a single character of pattern. The function should return true if such a bijective mapping is possible, otherwise false.

/*
Example 1:
Input: pattern = "abba", s = "dog cat cat dog"
Output: true

Example 2:
Input: pattern = "abba", s = "dog cat cat fish"
Output: false

Example 3:
Input: pattern = "aaaa", s = "dog cat cat dog"
Output: false
*/

bool matchPattern(const std::vector<std::string>& str, const std::string& pattern)
{
    
}