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.
In the for loop, we iterate through the each letter of the input string.
The logic first checks if it is vowel or not and then finds score.
Consider "banana" being the string, on first iteration, i value is 0 & the letter will be "b", find how many substrings we can from with this particular "b". They are : "b", "ba", "ban","bana","banan","banana".
6 substrings can be formed with this "b". That 6 is nothing but len(s)-i
Please reply back if you still didn't understand
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 →
In the for loop, we iterate through the each letter of the input string. The logic first checks if it is vowel or not and then finds score.
Consider "banana" being the string, on first iteration, i value is 0 & the letter will be "b", find how many substrings we can from with this particular "b". They are : "b", "ba", "ban","bana","banan","banana". 6 substrings can be formed with this "b". That 6 is nothing but len(s)-i Please reply back if you still didn't understand