The Minion Game

  • + 2 comments

    No, there is no need in some algorithm. In this case when you occurr a vowel letter you get the string length of remaining string starting with this vowel letter. I.e in "BANANA" word first vovel letter is A at 1 index position. Words count starting with this index is string_len - current_index = 6 - 1 = 5 [A, AN, ANA, ANAN, ANANA] . Then you get second A at 3d index position and words count in this case = 6 - 3 = 3 [A, AN, ANA] and so on. You can write "playerScore += (string_length - current_index)" what rp228068 did like "playerScore += len(string[current_index:])" but in this case you have to calculate string length = O(N) time complexity. Thus you get Time limit exedeed exception.