Ad
  • Custom User Avatar
  • Default User Avatar
  • Custom User Avatar

    Hey, @UniquePatel.

    First of all, you replied to an individual comment in order to ask for help. You should try not to reply to a comment unless the subject matter of your comment is truly in reply to that comment.

    Second, I'm not going to give you the answer, but I can tell you that any answer with permutations(list(str(positive_integer))) will time out. Pretty much no matter what you do after that. If you feed in a number with many digits, that will be a huge number of combination possibilities. You can't possibly iterate over all of them to see which is the minimum number that is bigger than the given integer.

    It seems you'll have to rethink your approach to this problem. Try and look at some of the example test cases or other examples done by hand and see if you can find a pattern. After all, this is a question of what algorithm gives the correct result.

  • Custom User Avatar

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

  • Default User Avatar

    Iterating up to N is not efficient enough. There's 100 tests with similar numbers that you tested, so that's why it times out.