Hi, Tried to solve it partial points. Could anyone suggests test case for BINFUN

Question: https://www.codechef.com/LTIME86B/problems/BINFUN

My solution: https://www.codechef.com/viewsolution/35992921

Any help is appreciated.

i and j both start from zero.

first mistake is that you are taking a[i],a[j] such that i<j…you should also consider cases in which i>j

second mistake binXplusY - binYplusX can be negative also so you cannot assign unsigned type to your variables binXplusY ,binYplusX as they will give wrong values when answer is negative.

Rectify these two mistakes and you are good to go…you will get partial marks

Thanks a lot, it worked

Why can’t we take i==j case too, then the worst case maximum value is 0. Question says ‘over all valid i and j’. Are we to assume valid i and j means i and j are unequal?

i==j case will give diff 0, that is minimum I can get

since string concat will be same both ways.

It is not clearly mentioned in the ques that whether i can be equal to j but i’m pretty much sure that you will get a positive answer from other cases(i>j or i<j) since one of the two (binXplusY -binYplusX) and (binYplusX -binXplusY) will be positive anyway if the two numbers are not equal.So even if you take i==j case also then,answer will not get affected.