Added runtime and space complexity