Pregunta de entrevista de Meta

I was asked two leetcode mediums