FastPrepIndex of the String with Most Vowels
Problems/Index of the String with Most Vowels

Index of the String with Most Vowels

Morgan Stanley logoMorgan Stanley● EasyINTERNONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Morgan Stanley onsite interview for interns. The author asks for the index of the string with the most vowels. The author also says they coded brute force first and then discussed optimization. We chose how letter case is handled, how ties work, what happens for empty input, the limits, and the interface.

Our version is about 90% the same as the reported question.

Given an array of strings words, return the zero-based index of the string containing the most vowel occurrences.

For this exercise, count a,e,i,o,u case-insensitively. Count repeated occurrences separately; y is not a vowel. If several strings tie, return the smallest index. Return -1 for an empty array. An empty string has zero vowels, so a nonempty array whose strings all have zero vowels returns 0.

Function

mostVowelIndex(words: String[]) → int

Examples

Example 1

words = ["sky","apple","AEIOU","queue"]return = 2

The vowel counts are [0,2,5,4]. Uppercase AEIOU contains five vowels, so its index 2 wins.

Example 2

words = ["","rhythm","bcd"]return = 0

The empty string, rhythm and bcd each contain zero vowels. The list is nonempty, so the smallest tied index is 0.

Constraints

  • For this exercise, assume 0 <= words.length <= 500.
  • For this exercise, assume each string has between 0 and 100 characters.
  • For this exercise, every character is an ASCII English letter, A through Z or a through z.

More Morgan Stanley Onsite Interview questions

  • Generate Strings of Length at Least ThreeONSITE INTERVIEW · Seen Sep 2026
  • Maximum Concurrent ProcessesOA · ONSITE INTERVIEW · Seen Sep 2026
  • Kth Largest Array ElementONSITE INTERVIEW · Seen Jul 2026
  • Run-Length Encode Consecutive Letter RunsONSITE INTERVIEW · Seen Jul 2026
  • Maximum Edge Removals for Two TravelersONSITE INTERVIEW · Seen Oct 2025
  • Remove K DigitsONSITE INTERVIEW · Seen Oct 2025
  • Count Ideal ArraysONSITE INTERVIEW · Seen Aug 2023
  • Distinct Palindrome PartitionsONSITE INTERVIEW · Seen Aug 2023
  • LFU Cache OperationsONSITE INTERVIEW · Seen Aug 2023
  • All-Pairs Shortest PathsOA · ONSITE INTERVIEW · Seen Feb 2022

Similar questions at other companies

  • Longest Common PrefixKotak Mahindra Bank · PHONE SCREEN · ONSITE INTERVIEWKotak Mahindra Bank interview questions
  • Map and Accumulate Learning QueriesPalantir · ONSITE INTERVIEWPalantir interview questions
  • Bounded Word Guess SolverAtlassian · ONSITE INTERVIEWAtlassian interview questions
  • Filter Pins by Excluded IDsPinterest · ONSITE INTERVIEWPinterest interview questions
  • Longest Common Parent DirectoryGoogle · ONSITE INTERVIEWGoogle interview questions
  • K-Second Message SuppressionMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Word Search Across DocumentsConfluent · PHONE SCREEN · ONSITE INTERVIEWConfluent interview questions
  • Retry with an Attempt LimitOracle · ONSITE INTERVIEWOracle interview questions
  • Extract Error Log ContextFlexTrade · ONSITE INTERVIEWFlexTrade interview questions
  • Compress Consecutive Integer RangesDocuSign · ONSITE INTERVIEWDocuSign interview questions

Interview reports that mention this question

  • Morgan Stanley Intern OOP Loops: 5 Experiences (Part 4 of 5)

Morgan Stanley interview experiences

  • Morgan Stanley Apprenticeship and Tech Interviews: 6 Experiences
  • Morgan Stanley New Grad Technology Analyst: 2 Experiences
  • Morgan Stanley Intern Oldest Loops: 5 Experiences (Part 5 of 5)
  • Morgan Stanley Intern Earlier Loops: 5 Experiences (Part 3 of 5)
  • Morgan Stanley Intern Tech Rounds: 5 Experiences (Part 2 of 5)
All Morgan Stanley interview questionsSee Morgan Stanley hiring insights
Saved
class Solution {
    public int mostVowelIndex(String[] words) {
        // Write your code here.
    }

}
Checking account…