Perf test 5 hot road

I’ve tried all the test cases suggested in this forum, still failing
my approach is first sorting the give list by register number and then using a 2 pointer approach.
I think there might be an issue with converting Register number to an integer, if so, could you give me a test case where it fails? @krishnadey-crio-ta

Hey Manjeet. I tried going through your logic of conversion and it was a little difficult to interpret. I faced the same problem debugging incase there is a mistake in your 2 pointer approach.

Try refactoring your code to enhance intepretability of logic (rewrite the entire code in a clean now since you are clear with your logic).Could you share your logic with me in the meanwhile so that i can help you out

Hey, so i’ll first tell my approach for the conversion part; how we can write 1234 as 1*10*10*10 + 2*10*10 + 3*10 + 4 = 1000 + 200 + 30 + 4 which gives 1234. so I have used this approach to convert the register number to integer

Now for the main Logic which is implemented in accomodatepPeople function, I use 2 pointer approach:
while (i != (len(broken) and j != (len(good)):
calculate distance
Now, if distance > k
check for the smaller register number and move that pointer ahead
else:
accommodate people from bad car to good car
check if capacity of good car is 0:
j = j+1 // move j ahead
check if passenger in bad car is 0:
i = i + 1 // move i ahead

Hey, @aritra-crio-ta ignore the previous reply, that was uploaded by mistake. I have mentioned my approach here

thanks for the correction, that was a typo

Hey @manjeetsingh10 Can you explain how your conversion works with KA27UT3953. Also have you made sure that you take the suitable datatype to fit in the converted integer? [Hint : int datatype might overflow in C++ so take long long where necessary]

Closing this topic as your issue is resolved by the mentor. If it is still not resolved, Kindly un-mark the accepted solution or create a new topic and post this question as a reference link in the description of the new topic.