Longest subsequence with one difference is { 1 , 2 , 3 , 4 , 3 , 2 }
int arr [ ] = { 1 , 2 , 3 , 4 , 5 , 3 , 2 } ; int n = arr . length ; System . out . println ( longestSubseqWithDiffOne ( arr , n ) ) ; } }