Longest subsequence with one difference is { 1 , 2 , 3 , 4 , 3 , 2 }
int arr [ ] = { 1 , 2 , 3 , 4 , 5 , 3 , 2 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << longestSubseqWithDiffOne ( arr , n ) ; return 0 ; }