(int arr[], int N)
| 30 | |
| 31 | // Sorting solution |
| 32 | static int findLongestConseqSubseq(int arr[], int N) |
| 33 | { |
| 34 | int count=1,counter=1; |
| 35 | Arrays.sort(arr); |
| 36 | for(int i=1;i<N;i++) |
| 37 | { |
| 38 | if(arr[i]-arr[i-1]==1) count++; |
| 39 | else if(arr[i]-arr[i-1]!=0) count=1; |
| 40 | counter = Math.max(counter,count); |
| 41 | } |
| 42 | return counter; |
| 43 | } |