Synopsys interview question

Basic coding questions from leet code.