Synopsys interview question

Algorithm test