So I'm trying to sort an vector <string> carInventory based on the order of a vector with 3 elements titled vector <string> promotionOrder.
Ex)
Input:
vector<string> carInventory {"mz", "my", "my", "mx", "mz", "mx", "my", "mz"}
vector<string> promotionOrder {"mz", "mx", "my"}
Output:
{"mz", "mz", "mz", "mx", "mx", "my", "my", "my"} //new carInventory
Here's the function:
vector<string> SortCar::sortCarInventory(vector<string> carInventory,
vector<string> promotionOrder)
What I have tried:
Currently stuck thinking of a solution with a time complexity of O(N) and <pre>with constant auxiliary space complexity O(1)