There is a guy named "Lucky" who is depressed now. His friend Jack knows why he is depressed. He has an array A which contains n numbers. He wants to find the largest sub-array where the first and the last element are same.
So Jack wants to help lucky. But he doesn't know anything about programming. That's why he comes to you as you are a great programmer in the world.
Find the size of the desired largest sub-array.
Note: a sub-array of an array composed from a contiguous block of the original array's elements.
The first line of the input will contain one integers n (the size of the array).
The second line contains n numbers. (A1,A2,A3,........,An)
Subtask 1 (10 points): 1 ≤ n ≤ 10 and 1 ≤ Ai ≤ 103
Subtask 2: (30 points): 1 ≤ n ≤ 2 * 105 and 1 ≤ Ai ≤ 106
Subtask 3: (60 points): 1 ≤ n ≤ 2 * 105 and 1 ≤ Ai ≤ 1018
Print the size of the desired largest sub-array.
6 1 2 3 4 1 5
Login to submit
|Long Practice Sessions on ISCPC 2019 Problems- 2|
|AUST CSE 44th Batch(1.1) Practise Contest 08|
|Sad Day To Die Hard|
|Practice Contest Before IUTCPC|
|National High School Programming Contest 2020 - Practice Contest|
|Mirror of SCB-PA Inter School and College Programming Contest 2019|
|SCB-PA Inter School and College Programming Contest 2019 - School Division|
|Bored in Quarantine|
|SCB-PA Inter School and College Programming Contest 2019 - College Division|