Cadence Design Systems interview question

C++ language knowledge Algorithm from leetcode