min and max pair for last k days problem