I broke down and wrote out each step in the process of the function. It was a bit confusing getting through it but once I switched to a simpler name it was manageable. I feel a bit more comfortable with the algorithm but at this time I don’t think I could code this in an interview with no review. I need to definitely work on these types of problems a lot more.
TLDR;
Okay, so here are the highlights of what I did:
- Still reading through the book “Cracking the Coding Interview” by Gayle Laakmann McDowell. Finished working on example twelve. After manually walking through an example with the string “Ben” I got an answer. Sadly, it was the wrong answer. I had been so focused on how the permutations were being produced in each loop that I failed to consider that the other processes involved with also impact the runtime calculation. Although I still caught an “L”, I think this process was beneficial and it highlighted how much more I need to practice with Big O runtime questions in general to re-affirm my process.
Conclusion
That’s all for today. If you are interested in the MIT course you can check out the video lecture I’m currently going through. The lecture is helpful but isn’t sufficient by itself. Anyways, until next time PEACE!