In a data cleaning pipeline, engineers optimize text datasets by alternately removing substrings: Alex removes substrings with an odd number of vowels in the first step, followed by Chris removing substrings with an even number of vowels in the next step.
Alex always goes first, then the engineers take turns optimally until no valid substring remains. The goal is to determine which engineer removes the last substring.
Implement a function optimizeDataCleaning to determine the outcome of the cleaning process for each dataset, assuming alternating and optimal cleaning.
The function optimizeDataCleaning takes the following input:
string datasets[n]: each string represents a dataset
The function should return an array of strings specifying the result of the cleaning process for each dataset.
Note: Vowels are 'a', 'e', 'i', 'o', and 'u'.
Example
Given n = 2 and datasets = ["git", "dry"]
This is a string game where Alex removes substrings with an odd number of vowels and Chris removes substrings with an even number of vowels, both playing optimally. The main challenge is not brute-force simulation, but reasoning about which substrings are legally removable and how that affects the game state. A good solution typically relies on game analysis or parity-based logic over the vowel distribution in each dataset.