Qualcomm Interview Question

write a program