https://medium.com/@AlexanderObregon/how-to-figure-out-the-time-and-space-complexity-of-a-solution-in-java-5036d6196ea3