Add optimal algorimt in sottomat.cpp