0

Given an array A consisting of N elements and Q queries of type [l,r]. Print the sum of all possible subsets in the range [l,r]. Example: A[]= { 1, 2, 3 } & l= 1, r= 3; Sol: print {1}, {2}, {3}, {1+2}, {1+3}, {2+3}, {1+2+3}

P.S I am using Segment trees with bit manipulation to find the sum of all possible subsets but it will give tle. Is there any optimized solution?

suraj bora
  • 61
  • 1
  • 11

0 Answers0