by AskAI

Solutions:

Check these solutions from our community and artificial intelligence:
This solution is correct and demonstrates a level of completeness. The approach is also optimal, as it has a time complexity of O(n).