Frage im Vorstellungsgespräch bei Applied Intuition

Leetcode hard style question. Parsing logic in Python should be strong.