The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | May 2017 |
| Last Sign in: | 398 Weeks Ago, 4 Days Ago |
| Questions Answered: | 66690 |
| Tutorials Posted: | 66688 |
MCS,PHD
Argosy University/ Phoniex University/
Nov-2005 - Oct-2011
Professor
Phoniex University
Oct-2001 - Nov-2016
You are given a string S. Your task is to find a longest substring of S, which is also the prefix of s and occurs atleast k times in s.
The input will contain 3 lines. First line will have an integer n, representing the size of input string.
The second line will contain a string S of length n. The third line will have k, as described in problem statement.
Output will consist of two lines. The first line will be length of longest such substring.
Print this substring in the second line.
14
abacabacabacab
3
6
abacab
String "abacab" is a prefix of s and occurs 3 times in s i.e s[1,6], s[5,10], and s[9,14].
Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n.P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll