Qualcomm interview question

it was not that difficult.