Solve a provided algorithmic problem and implement it in your preferred programming language (Python or C++).