I received an invite for an Amazon online test (Codility, Dublin, AWS, SDE). Not sure what the level of these questions are (applied with 2+ yoe). For non-trivial problems on the online test, does anyone know if I'm better off implementing a correct but possibly inefficient solution if I can't think of an efficient solution off the top of my head? Usually, I have the (unhelpful) habit of trying to think of more efficient solutions when none exist, wasting a lot of time in the process. Want to mitigate the risk of doing this.
Implement the brute force then go for the optimum
Approach each problem like so: 1. Write clean code. Make it readable. Make sure variables are named something useful, and spacing is consistent across the entire program. Add comments throughout the code explaining your thought process. It seems trivial, but trust me, you'll get some bonus points. 2. Start coding whatever solution pops into your head. Writing a working solution that compiles and passes all test cases is the most important thing. 3. Once you have a working solution, think about time and space complexity. Is this the most efficient solution? If it's not, write a comment in the code explaining your thought process. Remember, you have to show the reviewer what you're thinking, since you can't verbally tell them. 4. Try to optimize it. If you can't, or don't have enough time, that's okay; you've already explained in a comment your thought process on what the most efficient solution is. You will only lose a point or two, and worst case scenario, you get assigned a phone screen instead of the onsite. Good luck!
Thanks a ton! Super detailed and helpful.
Also, how is standard library use judged? E.g. for a k-th largest question, using the heapq library for heapselect. LC accepts solutions even if you simply sort and pick the index, which seems obviously insufficient.
Would you rather your car to be slow but takes you anywhere you wanna go, or be fast but breaks down everytime in the middle of the road?
Toyota all day