CDAP interview question

2 mid - hard coding problem