Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void removeRepeated() {
- if (source.length == 0)
- return;
- int newLength = 1;
- for (int i = 1; i < source.length; i++) {
- if (source[i] != source[i - 1])
- newLength++;
- }
- int i = 1;
- int[] newSource = new int[newLength];
- newSource[0] = source[0];
- for (int j = 1; j < source.length; j++) {
- if (source[j] != source[j - 1])
- newSource[i++] = source[j];
- }
- source = newSource;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement