Ad
  • Default User Avatar

    Instead of adding two while loop just use the insert command - a.insert(0, a.size() - b.size(), '0').

  • Default User Avatar

    Stop using reverse just initialise the loop from the end of the strings and run a backwards loop, reverse is adding to the time complexity and is anyway unneccesary step to worry about.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    Code is definitely cluttered, try to remove the unneccessary bool conditions and make it simpler to read

  • Default User Avatar

    A similar thing happened to me (I code in cpp not python), since it is a bigger code than normal, I first made the code in vs and then copied it here after running all the simulations I thought were needed.
    And moreover the error message was really ambigous.
    So I had to instead look at the testcases and identify in which testcase the problem was occuring.

    P.S. it was {{1}}

  • Default User Avatar

    I wanna add the fact that I checked many solutions that are using two loops and at first I thought that is an alternative to using variables such as gap(for index gap / margin) or counter(is a sense of direction), however they were used by others as well, so you really don't need to use more than one loop.