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.
My solution involves iterating over the string and check if the character in question is a consonant or a vowel. If the character is a vowel then the length of the substring from that character till the end of the string is to be added to kevin's last recorded score. This is because for each possible substring 1 point is awarded, so if you have a string 'abcd', here 'a', 'ab', 'abc' and 'abcd' substrings will go into kevin's favour, which means he will gain 4 points from all the substrings starting from 'a' and 4 is also the length of the substring starting from 'a' till the very end of the string. Similarly, while iterating over the string if the character is a constant then the length of the substring from the character till the end of the string is to be added to stuart's last known score. After the iteration is complete then the scores are compared and the appropriate result is displayed.
The Minion Game
You are viewing a single comment's thread. Return to all comments →
My solution involves iterating over the string and check if the character in question is a consonant or a vowel. If the character is a vowel then the length of the substring from that character till the end of the string is to be added to kevin's last recorded score. This is because for each possible substring 1 point is awarded, so if you have a string 'abcd', here 'a', 'ab', 'abc' and 'abcd' substrings will go into kevin's favour, which means he will gain 4 points from all the substrings starting from 'a' and 4 is also the length of the substring starting from 'a' till the very end of the string. Similarly, while iterating over the string if the character is a constant then the length of the substring from the character till the end of the string is to be added to stuart's last known score. After the iteration is complete then the scores are compared and the appropriate result is displayed.