implemented solution.cpp