Array ( [0] => [1] => questions [2] => Basic [3] => Slowest-Key ) HackwithInfy Previous Questions | Slowest Key | THE INQUISITIVE





Slowest Key

LEVEL:Beginner

Description

Alex wants to be a faster typist and is taking a typing test to find out which key takes the longest time to press.
Given the results of the test, determine which key takes the longest to press. For example, given keyTimes =[[0, 2], [1, 5], [0, 9], [2, 15]].
Interpret each keyTimes[i][0] as an encoded character in the range ascii[a-z] where a = 0, b = 1,...z = 25.
The second element, represents the time the key is pressed since the start of the test.
In the example, keys pressed, in order are abac at times 2, 5, 9, 15. From the start time,
it took 2 - 0 = 2 to press the first key, 5 - 2 = 3 to press the second, and so on. The longest time it took to press a key was key 2, or 'c', at 15 - 9 = 6.

Input Format

First line contains a number N denotes number of pairs
Next line contains a number M
Next N lines contains two integers speared by space

Output Format

A letter denoting the answer


Example 1:

Input
5
4
8 4
1 7
2 10
1 1
6 3
Output
i
Example 2:

Input
3
1
1 2
1 4
1 7
Output
b
Example 3:

Input
4
4
23 5
9 3
17 8
3 1
Output
x

oops

Login to see Discussion




Approach

Take required inputs and pass to function.
consider a empty list and append all consecutive differences into it.
Look up for maximum frequency that is highest difference.
Find the index and add 97 as ascii values for alphabets in lower case.
Return character of that ascii represented.


Note :

Let us know if you can come up with a better approach, mail us at support@theinquisitive.in Your approach will be reviewed and posted with credits to you.

oops

Login to see Solution