Given two strings pattern and s. The first string pattern
contains only the
symbols 0 and 1, and the second string s
contains only lowercase English
letters.
Let's say that pattern matches a substring s[l..r]
of s
if the following 3
conditions are met:
- they have equal length;
- for each 0 in pattern the corresponding letter in the substring is a vowel;
- for each 1 in pattern the corresponding letter is a consonant.
the task is to calculate the number of substrings of
s
that matchpattern
.
Note: In this we define the vowels as a
,e
,i
,o
,u
, and y
. All other
letters are consonants.
I am not challenging anyone here, I have tried different ways but could not achieve. This question was asked in codesignal test assessment recently.