chuzpa wrote:I haven't understood well if I should print the most frequent substring as lowercase substring, or just the most frequent substring found in it's least lexicographically way ...
Just ouput the most frequent substring as lowercase substring.
Suppose you are given a string of length 1000. And the query contains 1-1000. Then your code will return nothing but MLE. So, clear your map after each query. I used manual hashing and got it Accepted.
Hope these help.
In theory, there is no difference between theory and practice, but in practice, there is.
2
4
9
In theory, there is no difference between theory and practice, but in practice, there is.
2
4
9
I can't get rid of the PE.
If only I had as much free time as I did in college...
In theory, there is no difference between theory and practice, but in practice, there is.
2
4
9
2
4
9
In theory, there is no difference between theory and practice, but in practice, there is.
2
4
9
Regarding the capitalization, all you have to do is to convert the input string to lowercase right at the beginning. In other words, the ngram outputs will all be lowercase. Regarding MLE above with C++, I guess that demonstrates the convenience of Java's GC. This problem is so extremely straightforward with language like Java that I feel like I am cheating here. My Java solution was like <30 lines if we ignore the IO helper methods. So my point is, if you didn't get AC with C++ STL, but you really want to get it over with, then just try Java. It will take you less than 10 min, or 5 min if you type fast.
With the support of unordered_map, it is still possible to solve this problem by C++ STL. Just like other people said, this is a really straight forward problem. Good Luck
Have you ever...
Wanted to work at best companies?
Struggled with interview problems that could be solved in 15 minutes?