Added additional solution that improves space complexity by creating only one new variable vs. 2.