How to find indices and combinations that adds upto given sum?
问题 How to find the combinations and corresponding indices that adds upto given sum ? And also, can it be handled list of elements of size 500000 (higher size) ? Input: l1 = [9,1, 2, 7, 6, 1, 5] target = 8 **Constraints** 1<=(len(l1))<=500000 1<=each_list_element<=1000 Output: Format : {index:element} {1:1, 5:1, 4:6} #Indices : 1,5,4 Elements : 1,1,6 {1:1, 2:2, 6:5} {5:1, 2:2, 6:5} {1:1, 3:7} {5:1, 3:7} {2:2, 4:6} Tried: from itertools import combinations def test(l1, target): l2 = [] l3 = [] if