Explain the concept of Big O notation and analyze the time and space complexity of an algorithm you recently wrote.