TikTok interview question

Divide and conquer algorithm question in Python.