Select one model record for production using three ordered criteria: highest accuracy, then lowest latency, then latest ISO-format timestamp. Dates use YYYY-MM-DD, so their strings can be compared chronologically. Return only the selected model’s name.
Input: models = [{"name": "v1", "accuracy": 0.85, "latency": 120, "timestamp": "2024-01-15"}, {"name": "v2", "accuracy": 0.91, "latency": 95, "timestamp": "2024-02-20"}]
Output: "v2"
Explanation: Accuracy is the primary criterion, and v2 has the higher value.
Input: models = [{"name": "v1", "accuracy": 0.9, "latency": 100, "timestamp": "2024-01-10"}, {"name": "v2", "accuracy": 0.9, "latency": 80, "timestamp": "2024-03-05"}]
Output: "v2"
Maintain the best record while scanning the list once.
Compare accuracy first, then latency only on a tie, then timestamp only if both remain tied.
Sign in to take notes on this problem
Accepts: array
Select one model record for production using three ordered criteria: highest accuracy, then lowest latency, then latest ISO-format timestamp. Dates use YYYY-MM-DD, so their strings can be compared chronologically. Return only the selected model’s name.
Input: models = [{"name": "v1", "accuracy": 0.85, "latency": 120, "timestamp": "2024-01-15"}, {"name": "v2", "accuracy": 0.91, "latency": 95, "timestamp": "2024-02-20"}]
Output: "v2"
Explanation: Accuracy is the primary criterion, and v2 has the higher value.
Input: models = [{"name": "v1", "accuracy": 0.9, "latency": 100, "timestamp": "2024-01-10"}, {"name": "v2", "accuracy": 0.9, "latency": 80, "timestamp": "2024-03-05"}]
Output: "v2"
Maintain the best record while scanning the list once.
Compare accuracy first, then latency only on a tie, then timestamp only if both remain tied.
Sign in to take notes on this problem
Accepts: array