https://devdiwan.medium.com/calculate-space-and-time-complexity-of-an-algorithm-a-beginners-guide-de0ffeb09e7e