PF 2B Mock Exam
PF 2B Mock Exam
String
Question # 01: Max. Time: 20, Marks: 10,
Mr. Faisal wants a search feature for his language training website. One can submit a word as a
query and the site would return the meaning of that word from a language dictionary. A user
however, may sometimes have spell errors in his input. Mr. Faisal wants to take care of this and
wants to give him suggestions like "Did you mean this another word?". Mr. Faisal needs your
help. You need to write a program that would compare the proximity of two strings according
to a given set of rules designed by Mr. Faisal and decide whether one can be suggested for
another.
Input Description:
First line of input will contain an integer T = number of test cases. Next T lines will each contain
two strings consisting only of lower case English letters separated by space. Strings are
compared by these rules designed by Mr. X :
1. All the vowels plus the letter 'y' - set of characters: { 'a', 'e' , 'i', 'o', 'u', 'y' } are removed
from both the strings if they are present at any index other than 0. First letter is not
removed even if it's a vowel or 'y'.
2. Two strings are similar and can be suggested for each other if the first characters after
modification by rule 1 are the same and remaining characters after modification are not
different at more than 2 positions. If resulting strings after applying rule 1 are of
unequal length, all the extra indices in the larger string should be counted as having
different characters. e.g: if we get "bcd" and "bkd" after applying rule 1, they differ at
one position. "pqrs" and "pq" differ at 2 positions, (extra positions in "pqrs")
Output Description:
For each test case, print "YES", if the strings can be suggested for each other using the given
comparison logic, else print "NO".
Given a list of integers, find out the number that has the highest frequency. If there are one or
more such numbers, output the smaller one.
Input Description:
First line of input will contain an integer T = number of test cases. Each test case will contain
two lines. First line will contain an integer N = number of elements in the sequence and 1 <= N
<= 1000. Next line will contain N space separated integers of sequence A. For each Ai in
sequence A, 1<= Ai <= 10001.
Output Description:
For each test case, print on a single line, the number with highest frequency in the sequence.