Added final solution
Added algorithm