Memory Limit Exceeded in Python


#1

Memory limit exceeded even after using constant space apart from the final result.