We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
The table is actually misleading, it tries to count the occurence of each word in the whole string, making things way more complicated.
It will be much clearer to list all Stuart's word like this:
BANANA
BANAN
...
...
B
NANA
NAN
NA
N
...
...
Which concludes a much simpler logic to code:
For every word satisfies the condition, that word with last element removed will also satisfies the condition. And by iterating down the string, each word will occur exactly once.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
The Minion Game
You are viewing a single comment's thread. Return to all comments →
The table is actually misleading, it tries to count the occurence of each word in the whole string, making things way more complicated.
It will be much clearer to list all Stuart's word like this:
BANANA BANAN ... ... B
NANA NAN NA N ... ...
Which concludes a much simpler logic to code: For every word satisfies the condition, that word with last element removed will also satisfies the condition. And by iterating down the string, each word will occur exactly once.