by AskAI

Solutions:

Check these solutions from our community and artificial intelligence:
This is a good solution. It is recursive and correctly implements the algorithm. It is also optimal in terms of time and space complexity.