In this post I'll demonstrate a way to understand, analyse and reduce the time complexity on algorithms, specially on nested loops.
The examples w...
For further actions, you may consider blocking this person and/or reporting abuse
Once, at a job, I did this exact solution. We had a code to compare if something was in the loop. We had process an order of 31_000 records. Therefore, nested loop of 31_000 x 31_000 (don't ask me why, it was like 20 years ago :D).
I used the approach described here to avoid the nested loop and used the map instead. Voi la, instant win!
nice explanation thanks.
Thanks! That's one of the best descriptions of
O()notation I've ever read.However, can you please elaborate on the following example?
What is the relation of users and groups in your example? Many-to-many or many-to-one?
What is saved in the index? All users who belong to a particular group? Or a single user who belongs to a particular group?
Thanks! The relation between users and groups here are very simple. Please check out the Gist:
gist.github.com/leandronsp/70f9eff...
Let me know if needed more explanation.
Cheers!
Just recently learnt Big O and this article gives a good perspective, Thank you!!