Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int length = a.length;
- int diffCount = 1; //The number of different integers
- for(int i = 1; i < length; i++)
- {
- int b = a[i];
- int c = a[i-1];
- if(c>b)
- throw new IllegalStateException("unsorted array");
- if(c!=b)
- diffCount++;
- }
- return diffCount;
- diffCount += c != b;
- int b = a[i];
- int c = a[i-1];
- if (c != b) …
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement