Solved different Algorithms problem