Longest Arithmetic Stretch — Solution & Editorial
Extend the current run while the difference matches the previous one, else reset to 2.
Complexity: O(N)
Extend the current run while the difference matches the previous one, else reset to 2.
Complexity: O(N)