Algorithm Implementation Request
Name an algorithm and a target language to get a complete, ready-to-run implementation rather than just the core loop. - Typed main function with clear parameters and return values - Helper functions where the logic benefits from decomposition - Time and space complexity analysis - A runnable example call to verify it works
Implement a {{algorithm_name}} in {{language}}. Please include: 1. The main function with clear parameter and return types 2. Helper functions if necessary 3. Time and space complexity analysis 4. Example usage