Timer is Running

The Pattern Matcher
Submissions: 5490   Accuracy:


  Difficulty: Easy   Marks: 2
Associated Course(s):   Fork CPP

All right! Let's implement some pattern-matching using CPP strings.

You are given a string s of x and y. You need to verify whether the string follows the pattern xnyn. That is the string is valid only if equal number of ys follow equal number of xs.
As an example: xxyyxxyy is valid. xy is valid. xxyyx is invalid. xxxyyyxxyyxy is valid.

Input Format:
The first line of input contains T, the number of testcase. T testcases follow. Each testcase contains single line of input denoting the string s.

Output Format:
For each testcase, in a new line, print 1 if the string is valid else print 0.

Your Task:
Since this is a function problem, you don't need to take any input. Just complete the function follPatt(string s) that outputs 1 if string is valid, else it outputs 0.

1 <= T <= 100
1 <= |s| <=100



** For More Input/Output Examples Use 'Expected Output' option **

Author: Soul_xhacker

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.

to report an issue on this page.