Algorithm implementation part done!