Hey @vikaskodag98 Well your second implementation is a bit buggy. **It will fail at some test cases like: 24,32 ; 12 15 ; 65 90 etc…** Suppose the test case is (12,15) then your program will evaluate ‘sum’ initially as 54. Since you are iterating from last number i.e. 15, a[15]=1 (as sum= 54 is well greater than i=15) and it continues till i=13 where sum remains to be 25. Here your program decrements i as (sum-i)==x gets true(since x=12 here).

Now you are left with i=12 and sum= 25 and since (sum>i) gets true in your second if block **you evaluate a[12]= 1 which is wrong.**