|
|
вернуться в форумan easy method (Please forgive me for my poor English.) First,use Hash to record ai Then,enumerate i,j as the first and the second items in the arithmetic sequence.check if 2*a[i]-a[j] exists.If it exists,we stop it immediately because the arithmetic sequence has been found.Otherwise,we find the arithmetic as brute force and mark the longest arithmetic sequence. At last,it's easy to restore the arithmetic sequence. So we can solve it in O(n^2). Edited by author 20.08.2021 13:43 |
|
|