Leetcode 399 Python Optimize Root Canal Procedure