Given a package with a weight limit limit and an array arr of item weights, implement a function getIndicesOfItemWeights that finds two items whose sum of weights equals the weight limit. The function should return a pair [i, j] of the indices of the item weights, ordered such that i > j. If such a pair doesn’t exist, return an empty array. input: arr = [4, 6, 10, 15, 16], lim = 21 output: [3, 1] # since these are the indices of the weights 6 and 15 whose sum equals to 21

© Kimi Tsai all right reserved.            Updated : 2024-05-06 09:36:37

results matching ""

    No results matching ""