I’m reviewing my Leetcode Java submissions and tho...
# getting-started
I’m reviewing my Leetcode Java submissions and thought, I’d see what the code would look like with the Automagic to Kotlin conversion from Studio. One problem that I solved with updated Kotlin code seems to be less performant (by Leetcode benchmarking) 🤔 Maybe I’m not hitting their servers at the right time 😛 https://leetcode.com/problems/move-zeroes/discuss/1664500/Java-to-Kotlin-Converted-Solution%3A-Less-Performant-with-Kotlin
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
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)
is their Kotlin runner compiling to JVM or using the scripting engine? the timing makes it look like the latter
(but I haven't messed around with leetcode to see if that holds up elsewhere)
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.