I am getting TLE in Leetcode on question 29. Please help me optimize.
I am using the most efficient code that I could understand. Please suggest how to optimize it for the test case where the dividend is int_max and divisor is -1.
5 Replies
⌛
This post has been reserved for your question.
Hey @theash2473! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose Post
button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
The case is giving int_min when it multiplies int_max by 2 in the for loop which should be the condition at which it gets out of the loop but it is creating infinite loop instead.
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.
I am not able to get the code right. I tried optimizing the code but I can't get to the correct solution.
This is the current one I am having. It seems that the most optimized code is the only one which is the solution. No other code will be able to work.
In this code, the edge cases are not able to be incorporated in the code. which is having
(dividend = int_max , divisor=-1 )
or vice versa.
Something is missing always.
Would someone like to take a look in this code and help me?
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.