Roman Numerals in Strings
You are given a string that contains a name followed by Roman numerals.
Your task is to return a vector of strings that stores:
- 1. The string name.
- 2. The numerical value of the Roman numeral (converted to integer).
The names should be in ascending order, and if the names are the same, the numbers should also be sorted in ascending order.
Input Format:
- A list of strings where each string is in the format: name RomanNumeral.
Output:
Return a vector of strings, sorted by name and numeral value.
Notes:
- The Roman numeral, when converted to a number, is at most two digits.
1Example 1
The names and their corresponding Roman numerals are sorted in ascending order. The Roman numerals are converted to integers as follows:
- IX -> 9
- XV -> 15
- VIII -> 8
- IX -> 9
The sorted output is: ["John 8", "John 9", "Mary 9", "Mary 15"].
Constraints
Limits and guarantees your solution can rely on.
๐๐