Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
fixed
Yup, that is the correct observation, thank you very much :)
Oh interesting! I like your solution.
some of us havent got to space/time complexity lol
In theory, yes. Bust in many cases the time saved by using a wildcard is more important. Plus, you can limit your sample to, let's say, 100 rows and not worry about how many columns you have there anymore.
See https://en.wikipedia.org/wiki/Fibonacci_number#Closed-form_expression
phi=(sqrt(5)+1)/2 = 2/(sqrt(5)-1) ~= F(n+1)/F(n) for large n. So F(n) ~= F(n+1)/phi, where by ~= I mean "approximately equals". It turns out the round function can be used since F(n+1)/phi will be within 0.5 of F(n).
I think so because the query will be ran for every row, rather than once and then groupped
Same Big-O complexity ( either
O(n log w)
,O(n log n)
orO(n^2)
) depending on the complexity of counting / looking up items.With small
arr
, there can be no re-allocation.We can improve that with a pre-allocated array:
visited := make([int]*int, len(arr) - 1)
.Nothing says the inmutability of
age
needs to be preserved. Actually it doesn't.@mreza-dehghani: you can use a slice to preserve the original array:
_data = ages.slice().sort(...
so what is your solution??
thanks for your feedback
There's no need for spam, even if your messages are meant to be helpful.
Thanks, I"m pretty new in golang world :) Love your solution!
Yes, I would only use
make([]int, 0, n)
when then
is known beforehand, otherwise let theappend
manage allocation. And in the Go production code you may use profiling: https://golang.org/doc/diagnostics#profilingLoading more items...