NEC Corporation interview question

diamond problem