Spoj subsum doubt

cant understand how to compare negative numbers and whats going wrong in the code , also please explain what to do to overcome the overflow issue

@rohit_1906 can you send me the question link I cannot see the question through your content

ya sure

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

Hey @rohit_1906
How can I help you ?

i have sent the question’s link above and my code link also , cant understand how to compare negative numbers and also the overflow issue

@rohit_1906
Your approach is not correct
Since we have n upto 34 your code will run max upto 2^34 which gives obvious TLE
To solve this you need to divide input array into 2 parts of equal sizes
Then calculate and store possible sum values from first half = 2^17
Then calculate and store possible sum values from second half = 2^17
Then you need to find pairs in set1 and set2 which total to sum
If you have X in set1 then see if Sum-X is there is set2
there may be 2^17 possible X in set1 then for find pair it becomes 2^17 again
Try to solve the question this way

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.