Cadence Design Systems interview question

the question consists of algorithms question cpp code question