UVa 902 - Password Search

902-Password Search

Summary
Given a string you have to find the most frequently occuring substring of a given length

Explanation
Usage of maps form STL in C++ will make the problem quite easy. Making a vector/array and counting the frequencies is doomed to time out.

Implementations
mapmymap; map::iterator it; for(i=0;imax){res=(*it).first;max=(*it).second;} } cout<<res<<endl;

Input
1 thequickbrownfoxjumpsoverthelazydog 3 thequickbrownfoxjumpsoverthelazydog 4 testingthecodetofindtheerrortestandtestagain 5 thearraycanbetoobigsobecarefulandtherecantberarecasescanbe

Output
o the test canbe