r/codinginterview • u/d3rp1n4_d3rps0n • Jul 23 '19
Big O - practice?
Hi - Last week I did the interview exam at Amazon. I answered the 2 coding exercises (all tests passed), but after that part I was asked to provide the complexity for my solutions. I believe that's the part I failed as I got an 'unfortunately....' email back.
I left college long time ago, and to be honest I do remember the basics for big O (like O(1) is linear/single expression, O(n) is for cycles, O(n^m) is for when we have m nested cycles, and so on), but as this is not something I calculate daily on my current job, I was thinking on review it again, just in case I got a call from any other company (I'm not actually looking for a new job, I just want to take the opportunities I get and, if an offer is appealing, well... maybe I move)
Anyway, does anybody know of a good site/book to review & (most important) PRACTICE Big O? A friend just borrowed me his 'Cracking the coding interview' book. I'm doing the exercises and calculating the Big O as I know/remember, but I don't know if that is OK or not (the book doesn't provide such info per solution to the exercises).
I also found some sites (like this: https://rob-bell.net/2009/06/a-beginners-guide-to-big-o-notation/). But same thing: I'm calculating the Big O in the same way I did for the interview, and I don't see the error in my response, so I would like to know if there is a better site/reference to practice big O.... maybe?
Thanks in advance!
1
u/d3rp1n4_d3rps0n Sep 24 '19
I know this is an old post, and probably nobody will see this, but: I bought this book and it was exactly was I was looking for:
Elements of Programming Interviews in Java - https://www.amazon.com/Adnan-Aziz/dp/1517671272/ref=sr_1_1?__mk_es_US=%C3%85M%C3%85%C5%BD%C3%95%C3%91&crid=2U0T3YHSBVWQB&keywords=elements+of+programming+interviews+in+java&qid=1569364446&sprefix=elements+of+p%2Caps%2C197&sr=8-1
It has lots of exercises to practice, but best thing is that it has the Big O explanation for each one of the exercises so you can practice that too - And if you get it wrong, then you will know why.
Seems there is a Python and a C++ version. I don't know if they actually have same samples/Big O details.