Not sure how leetcode performs benchmarks but this would need be repeated a number of times in order to be significant.
Also, does this count the compilation time as well?
That said, I don't see anything obvious with the converted solution, apart maybe from the use of
.indices
which might not benefit from the ranges optimizations (although I doubt it's not optimized).
Did you try this:
Copy code
for (i in 0 until nums.length)
?
e
ephemient
01/03/2022, 5:46 PM
is their Kotlin runner compiling to JVM or using the scripting engine? the timing makes it look like the latter
ephemient
01/03/2022, 5:47 PM
(but I haven't messed around with leetcode to see if that holds up elsewhere)
s
sorianog
01/03/2022, 6:04 PM
Appreciate the info and responses you 2.
Joffrey, I tried what you suggested and got the following:
• 01/03/2022 10:03
• Accepted
• 583 ms
• 62.7 MB
If anything, I can do my own benchmarking locally to verify some things.