Tatari Interview Question

How did you implement the algorithm in the assignment?