ITADN

Faster implementation using math.Abs and switch

#81Pull Requestmick4711 创建于 2024-10-20已合并
M
mick4711commented
#### Is your solution the most efficient way to solve a problem? Why? - It's twice as fast as current solution #### Have you used any specific algorithm? - No, it uses math.Abs instead of hand written abs function. - I think using 'switch' for co-ord check is a little more readable than the 'if' check - I use co-ords based on 1 instead of 0 for readability. #### What is time and space complexity of your solution? - time is a half of current solution (120 ns/op vs 240 ns/op) on my machine - I don't think there are any space issues, 58 lines of code vs 38.
合并状态:已合并 合并于 2024-10-20 关闭于 2024-10-20 1 条评论