Adding solution for sum of min and max