Good morning, I recently started practicing on Lee...
# random
d
Good morning, I recently started practicing on LeetCode using Kotlin, and I experienced something weird. Given the script posted here, there are 4 test cases on LeetCode, all of them passes in a kts file ( scratch file in a project with Kotlin 1.6.21 ) and only for one of them we have an incorrect output on LeetCode only. Do you have any idea about it? Test cases in the thread
LeetCode vs kts file
s
For issues like this, I would recommend that you break your program down and debug the individual parts to make sure that they do what you expect. I think the issue that’s causing you to fail the test case is to do with the way you’re converting the linked list into a mutable list. Check that the values
first
and
second
each contain the values you expect in the correct order.
My guess is that the reason it appears to pass when you run a local Kotlin script is that you have the same conversion error when setting up the test inputs, and the two errors cancel each other out.
d
you have the same conversion error when setting up the test inputs
That’s a pretty nice guess! I’ll read the article as well! Thank you so much
r
If you haven't found an error by now, try this input:
[1, 1]
and
[9]
if I'm looking correctly, that should make it clear what's happening
d
I'll give it a try after work, thanks
[1, 1]
and
[9]
passes
@Sam, you were right! Fixing the input “formatter” the mistake got revealed 😄
🎉 1
👍 1