Ultra fast mathematician

I wrote the code and passed all the test cases successfully but what if the input was like
1
10111 100011101
Do we need to traverse from the end of both the strings and then will compare the characters of the larger string with 0?
Is there any other optimal way to do this sum like using or operator and we can get output in O(1) for each test case.
Can anyone give an idea of how to implement it for the above test case?

@mohitsethia hey according to constraints, the numbers are going to be of equal length. Now suppose even if the numbers are of different length we should handle them the same way we add two numbers of different number (append zeros in the starting to make both equal)
We are basically taking xor of two numbers, their is xor operator to do it, but the given constraints make it impossible for any primitive datatype to hold them, so we must do it manually and it will take O(n).
If this resolves your doubt mark it as resolved.

The inbuilt append function appends at the end of the string, right? So, first we need to append the difference of the two string as the number of zero’s in the starting and then append the shorter string. Okay.
Since the digits can be we very large so we are using strings, else we can use integers and use xor operator to do the operation O(1) time.

@mohitsethia Yes we append zeroes at the starting. If this resolves your doubt mark it as resolved.

I already marked it as resolved

1 Like