0

I'm struggling with this quite a while, how can i convert the first line into the second? Thanks very much in advance!

int mm [] [] = new int[][] {{10, 30},{30, 5},{5,60}};
int mm [] = new int[] {10, 30, 5, 60};
shmosel
  • 49,289
  • 6
  • 73
  • 138
  • 6
    Possible duplicate of [How to flatten 2D array to 1D array?](http://stackoverflow.com/questions/2569279/how-to-flatten-2d-array-to-1d-array) – shmosel Dec 04 '16 at 21:44
  • 1
    Are you using java 8? – 0x6C38 Dec 04 '16 at 21:45
  • 2
    `Arrays.stream(mm).flatMapToInt(Arrays::stream).distinct().toArray()` – shmosel Dec 04 '16 at 21:46
  • 1
    You are converting three elements into four? What is the algorithm you are thinking of? Seems like you are collapsing similar numbers? – Einar Dec 04 '16 at 21:47
  • These are 3 matrices with the dimensions 10x30,30x5,5x60. The input needs to be in the form of line 1 and should then convert to the form of line 2 in order to make my programm work. – javaenjoy Dec 04 '16 at 21:59

0 Answers0