A.P. Array
Practice
5 (2 votes)
Easy
Problem
47% Success 503 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code
Given an array A of length N . Find the length of longest subarray which forms an arithmetic progression .
For example if the array is \([3,5,2,4,6,9]\) then subarray \([2,4,6]\) forms an A.P. with common difference 2 having maximum length 3 .
INPUT
First line of input contains one integer N number of elements in array.
Second line contains N elements .
OUTPUT
Print the length of longest arithmetic subarray .
CONSTRAINTS
\(2 \leq N \leq 10^{6}\)
\(-10^{6} \leq A[i] \leq 10^{6}\)
Submissions
Please login to view your submissions
Similar Problems
Points:20
144 votes
Tags:
Ad-HocOpenApprovedSimple-mathEasyMathamatics
Points:20
Tags:
ImplementationEasyMath
Points:20
1 votes
Tags:
Easy
Editorial