Phase 4b (Problem Solving) ii. Given an array of integers, find the longest subarray where the absolute difference between any two elements is less than or equal to 1. Example There are two subarrays meeting the criterion: and . The maximum length subarray has elements. Function Description Complete the pickingNumbers function in the editor below. pickingNumbers has the following parameter(s): int a[n]: an array of integers Returns int: the length of the longest subarray that meets the criterion Input Format A = [1,1,2,2,4,4,5,5,5] The first line contains a single integer , the size of the array . The second line contains space-separated integers, each an . Ans: [4,4,5,5,5] Constraints 2<=n<=100 0< a[i]<100 The answer will be >=2 6 4 6 5 3 3 1 Answer: 3 {4,3,3} 6 1 2 2 3 1 2 Answer: 5 {1,2,2,1,2}
Sigiloso
They picked the question from HackerRank and didn't even format it properly.