Pregunta de entrevista de Urban Company

two medium level leetcode dsa question