Added solution for #25
Solution based on yinzhu's algorithm