AT&T Interview Question

they asked me to solve a tough coding problem.