Pergunta de entrevista da empresa Kulicke and Soffa

Write a function in Python/C++ for this problem