Algorithm solutions