ans to store the maximum value of the equation.points.xj, yj, pop out all points from the priority queue that have xi values more than k distance away from xj.ans if it's greater than the current ans.yi - xi along with xi into the priority queue.ans as the result.