In golang when you pass a parameter to a function it will make a copy of it, unless pointer type is specified (eg arr *[]int). So this function is pure.
I agree. I was extremely new to programming when I did this and I can already see this is a very sub-optimal approach, I wouldn't call it clever nor best practice.
i dont understand why this is best practice. this code just iterates throw every number... ofc it ll word fine with input 100000, but if we try to calculate 10000000000000 it ll work half day...
u could do that at one liner
In golang when you pass a parameter to a function it will make a copy of it, unless pointer type is specified (eg
arr *[]int
). So this function is pure.This comment is hidden because it contains spoiler information about the solution
sweet. didn't think of this.
i enjoyed it bro
Oh nice!Didn't realise python had this swapping functionality built in.
I'm glad I'm not the only one who actually defined the init method to solve this.
better not to overcomplicate :))
I agree. I was extremely new to programming when I did this and I can already see this is a very sub-optimal approach, I wouldn't call it clever nor best practice.
i dont understand why this is best practice. this code just iterates throw every number... ofc it ll word fine with input 100000, but if we try to calculate 10000000000000 it ll work half day...
better to use tuple instead array