Question: Question A person has invented a machine that outputs the most frequently occurring characters in a string that lie in the range L , R
Question
A person has invented a machine that
outputs the most frequently occurring
characters in a string that lie in the
range The machine accepts a
series of characters and asks the user
to input two numbers, and The
machine outputs the characters for all
the pairs of values the user
provides.
Write an algorithm to help person find
the output for all the inputs they
provide.
Input
The first line of the input consists of a
string strS representing the series of
characters that are fed to the machine
initially.
The second line consists of two space
separated integers numPairand
valPair, representing the number of
pairs provided by the user and
number of values in each pair
always respectively.
The next lines consist of space
separated integers vall and valR,
representing the values of the lower
and upper range for the pairs
respectively.
Output
Print a string consisting of
characters representing the most
frequently occurring characters for all
the pairs of inputs the person
provides. If more than one character
in a particular input has the same
frequency, print the character that is
least in the lexicographic order.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
