I have written this code in ciel and A-B output is right but it say wrong answer help
You just changed the most significant digit i.e the left most digit to 1 …
But what if it was already one ??
For example 43-31 = 12 now u did d[i-1]=1 (which was already one)
So u didn’t even changed the number
in your code with,
if(d[i-1]!=1) d[i-1]=1; else d[i-1]=2;
And you are ready to go…