Loading...
Loading...
You are given a 2d list of integers queries, a 2d list of integers keys, and a 2d list of integers values. Each query is a list of m integers, and each key is a list of m integers, and values[i] is the value paired with keys[i]. All values have the same length.
The score of keys[i] for a query q is the sum of q[j] * keys[i][j] over every index j. The lookup result for q is values[i], where keys[i] is the key with the largest score.
Return a 2d list holding the lookup result of each query, in the same order as queries.
You can assume that for every query, exactly one key reaches the largest score.
queries.length ≤100keys.length ≤100values.length = keys.lengthqueries[i].length ≤50queries[i].length = keys[j].length for every i and jvalues[i].length ≤50values[i].length = values[0].lengthqueries[i][j] ≤100keys[i][j] ≤100values[i][j] ≤104The query scores 1 against the first key and 0 against the second, so the result is [[10]].
The first query scores 1, 2 and 0 against the three keys and the second scores 0, 0 and 1, so the results are [7,8] and [9,10].
The scores are -1, 1 and 9, so the third key wins and the result is [[2,2]].