Painter problem

when i run this code it i reaching end of function. what is wrong in the code ?

@Raghavsingla522

  1. You need to return something at the END of the for loop, not inside it.
  2. You are initialising ans with INT_MIN and then choosing min(ans, mid) ofc the answer will never get updated. Initialise it with INT_MAX instead.
  3. What is the logic behind multiplying s and e with 5? Time can vary.

ya okay i removed those silly mistakes.
but now when i submitted it is not passing most of the test cases.

@Raghavsingla522 yeah your helper function has some logical mistakes, try to figure it out by running it for different test cases. I will help you out if you are stuck :slight_smile:

1 Like

i tried but not able to pass all test cases with my code . please check this https://ide.codingblocks.com/s/263549

@Raghavsingla522 i dont think there is a need to multiply everything with t in the beginning. Like just find the answer for t = 1, and multiply that with t in the end. You may refer to this code

@Ishitagambhir okay i got all the test cases passed now . thanks for the help. :relaxed:

1 Like