During your computer examination, you are given a question to find whether a given word is valid if it can be typed using only one row of the given keyboard pattern.
You are given an integer N where N denotes the number of rows in keyboards. You are given an array of string keyboard where keyboard denotes the key sequence of each row i.e. keyboard[i] denotes the key sequence of ith row. You are given a string word that you need to validate.
Task
Return 1 if the string word is valid else 0.
Example
Assumptions
Approach
All the letters of string once are present in the first row of the keyboard.
Therefore return 1.
Function description
Complete the Solve() function provided in the editor below that takes the following arguments and returns 1 if the string word is valid else return 0:
Input format
Output format
Print 1 if the string word is valid else 0.
Constraints
keyboard[i] contains lowercase English alphabets and can contain at max 26 letters without repetition.
words[i] contains lowercase English alphabets and can contain at max 106 letters.
All the letters of string once are present in the second row of the keyboard. Therefore return 1.