Qualcomm Interview Question

Basic logic and coding questions.