Company: flipkart_20aug
Difficulty: medium
Most Frequent N-gram Problem Description The term N-gram refers to all possible substrings of length N and formed using consecutive letters contained in a string. Given a string S and an integer N, find the most frequent N-gram in the number of times it appears in S. If there is more than one N-gram with the same frequency, output the first one that appears in S. Read the input from STDIN and print the output to STDOUT. Do not write arbitrary strings anywhere in the program, as these contribute to the standard output and test cases will fail. Input Format A single line of input contains S and N separated by a single white space. Output Format The output contains a string denoting the most frequent N-gram and an integer denoting the number of times the N-gram appears in S, separated by a single white space. Examples Example 1: Input: banana 3 Output: ana 2 Explanation: The string S is 'banana' and the N = 3. All the N-grams and their associated frequency are: ban 1 ana 2 nan 1 The most