A Queue is being used as a sliding range with 250 integers of 2500 integers in a Linked List. In each iteration, the Queue is moved one position forward on the Linked List by Dequeuing and then Enqueing the next integer in the Linked List. Every time the Queue slides one position, the Max integer of the Queue is found by iterating through nodes in the Queue.
Can this process be sped up by replacing the iteration to update the max with calculating the newMax from the variables previousMax, dequeued, enqueued and sumOfPreviousQueue? This seems like it should be possible with arithmetic, but I can't figure it out.