Added algoritm for problem