some algorithm solutions