Cognex Interview Question

coding question related to dsa