• + 1 comment

    Nice algorithm. However I'd prefer if you described your approach, rather than posting your code. (This would also avoid people asking "can you explain your logic".) Leave the coding as an excercise for the reader :)