C ++ code to find longest subarray with difference between max and min as at - most 1.
#include <bits/stdc++.h> NEW_LINE using namespace std ; int longestSubarray ( int input [ ] , int length ) { int prev = -1 ; int current , next ; int prevCount = 0 , currentCount = 1 ;