Domanda di colloquio di Alation

H-index question from Leetcode as it is