Domanda di colloquio di F5

Technical question from leet code. 1 medium and 1 hard problem