codes for algorithm problems