IBM Coding Question β Solved
getQueryAnswers
In a machine learning model, there are n data entries stored in the model's output cache cacheEntries. Each entry contains three values:
1. timestamp β when the prediction was made.
2. modelId β the identifier of the machine learning model.
3. predictionValue β the model's output, represented as a string containing an integer.
A query handler receives q queries in the form of queries[q][2], where each query consists of:
- modelId β identifying the machine learning model.
- timestamp β specifying the time at which the prediction was made.
Implement a function getQueryAnswers that:
- Takes two inputs:
- cacheEntries[n][3]: A list of cached predictions.
- queries[q][2]: A list of queries.
- Returns an array of integers, where each value corresponds to the predictionValue for the given modelId and timestamp.