Getting Wrong answer

Check this out

@vg5823967,

In query function, in the case of no overlap you are returning {INT_MIN , INT_MIN , INT_MIN , INT_MIN} (say =waste), now later in the query function, you will use these values to merge from left and right, which would be result in wrong values (eg temp.totalSum=INT_MIN+right.totalSum)

Try this,
if(left==waste) return right;
if(right==waste) return left;

Also values may be large, use long long as data type.

Getting Compilation error https://ide.codingblocks.com/s/198420

@vg5823967,
because the == operator only works for implicit datatypes, you can’t use it to compare object of your class.

  • Either overload the == operator in your class.
  • Or just write a function that compares 2 objects of your class.