### From Chen's Wiki

### Rotation

<Rotate Array>:

self.reverse(nums, 0, size-k-1) self.reverse(nums, size-k, size-1) self.reverse(nums, 0, size-1)

### Linked list

<linked list cycle>: slow/fast pointer: if no cycle, fast gets to None. Else, fast will meet slow.

while fast and fast.next: slow = slow.next fast = fast.next.next if slow == fast: return True

### Greedy

<Candy>: Two pass

for i in range(1, N): if ratings[i] > ratings[i-1]: C[i] = C[i-1]+1 for i in range(N-2,-1,-1): if ratings[i+1]<ratings[i] and C[i+1] >= C[i]: C[i] = C[i+1]+1