Vowel Substring Deletion Game
Updated
Problem statement
For each string in datasets, Alex and Chris take turns deleting a nonempty contiguous substring. Join the parts on either side after each deletion.
- Alex moves first and may delete a substring containing an odd number of vowels.
- Chris may delete a substring containing an even number of vowels. Zero is even.
- A player who has no legal move loses. Both players choose moves optimally.
Return "Alex" or "Chris" for each input string, in the same order.
For this exercise, vowels are a, e, i, o, u.
Function
determineWinners(datasets: String[]) → String[]Examples
Example 1
datasets = ["git","dry"]return = ["Alex","Chris"]In git, Alex can delete the entire string. In dry, Alex has no legal first move and loses; Chris does not need to make a move.
Example 2
datasets = ["ae","bcdf","aba"]return = ["Alex","Chris","Alex"]For ae and aba, Alex can leave exactly one vowel. If Chris has no legal move, Chris loses immediately. Otherwise Chris can delete only consonants, leaving that vowel for Alex to remove on the next turn. For bcdf, Alex has no legal first move and loses.
Constraints
- For this exercise, assume
1 <= datasets.length <= 100. 1 <= datasets[i].length <= 1000.- Every string contains only lowercase English letters a through z.
More JP Morgan Chase Online Assessment questions
- Find Total CostOA · Seen Oct 2026
- Minimum Meeting RoomsOA · Seen Oct 2026
- Count Dropped RequestsOA · Seen Oct 2026
- Maximize Minimum Deployment DifficultyOA · Seen Oct 2026
- Task SchedulingOA · Seen Oct 2026
- Substring RemovalOA · Seen Oct 2026
- Maximum Game Board ScoreOA · Seen Sep 2026
- Minimum Digit Changes Between String HalvesOA · Seen Sep 2026
- Same Substring Within BudgetOA · Seen Sep 2026
- Invert Ad Visibility BitsOA · Seen Aug 2026
Similar questions at other companies
- Perfect Squares Matching a PatternNielsen · OA
- Simplify a Quadratic ExpressionOpenAI · OAOpenAI interview questions
- Next Number with Disjoint DigitsElevenLabs · OAElevenLabs interview questions
- Vowel Substring GameAkuna Capital · OAAkuna Capital interview questions
- Minimum Anagram PeriodVisa · OAVisa interview questions
- Return Exact Cash Register ChangeBank of America · OA
- Maximum Equal Parts for PrefixesAmazon · OA
- Minimum Anagram PeriodWells Fargo · OAWells Fargo interview questions
- Minimum Digit Swaps for the Smallest DifferenceLSEG · OALSEG interview questions
- Prime StringSnowflake · OASnowflake interview questions
Interview reports that mention this question
JP Morgan Chase interview experiences
- JPMorgan Quant Stats Superdays: 3 Experiences (Part 3 of 3)
- JPMorgan Quant Modeling Superdays: 7 Experiences (Part 2 of 3)
- JPMorgan Quant Intern Superday: 19 Experiences (Part 1 of 3)
- JP Morgan Chase Data and AI Intern Superday: 11 Experiences
- JPMorgan Code for Good India 2024: 6 Experiences (Part 5 of 5)