# CHEFSUBA:- Later Part Clarification

Hi,

Here my solution for the problem CHEFSUBA. I can not understand the later part of the problem when `k<n`. How should we approach it, if k=3 and n=5, should we iterate in this frame for 3(5-3+1) times or take it once, for n, collectively? I have used repetition to avoid the rotation, If any hint/explanation can be provided, It will be great as I desperately want an AC for this problem.

Instead of Segment Tree we can use a Linked List of size of number of frames i.e n-k+1 .Then we calculate maximum from the Linked List.When we perform rotatation we delete the back of linked list and (increment/decrement/no change) to front of the Linked List.We also keep an index for which we have our maximum.If we maximum frame element was at back of Linked List then that would have been deleted in each rotation that means we search linearly along the frames once more.Other case is that back element was not maximum then all we have do it compare with front element which might incremented and hence become the new maximum.