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.
Use frozenset for the vowels. This is the fastest to lookup in.
Iterate through characters instead of indexing
Iterate q reverse to avoid a subtraction in each sum
Avoid repeated calls to len
Only calculate Kevins score the hard way. Use the fact that the total number of substrings is n * (n + 1) / 2 and find Stuart's score by subtracting Kevin's from the total number of substrings.
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 →
Python 3
Several optimizations.