Pergunta de entrevista da empresa Xilinx

Easy overall, with one Medium leetcode question.