You are given an array A consisting of N integers. A subsequence of the array is called good if every pair of elements in the subsequence have an absolute difference of at most 10.
Task
Determine the maximum possible length of good subsequence.
Example
Assumptions
- N = 8
- A = [1, 9, 14, 2, 17, 14, 5, 18]
Approach
- Subsequence: [9,14,17,14,18] is good which is the maximum length subsequence.
- Hence the output is 5.
Function description
Complete the function solve() which takes the following 2 parameters and returns an integer as the required answer:
- N: Represents an integer denoting the size of the array
- A: Represents an array of N integers
Input format
Note: This is the input format you must use to provide custom input (available above the Compile and Test button).
- The first line contains an integer N.
- The second line contains an array A of N integers.
Output format
Print the maximum possible length of good subsequence.
Constraints
\(1 \leq N \leq 10^5 \\ 1 \leq A_i \leq 10^9\)
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Login to unlock the editorial