So I have been trying to fix this by myself but I didn't find enough info on the subject.
In the next code, there is a function that receives an array of a linked list (Integer), the array is a representation of a square that has black and white squares inside (1 = white, 0 = black), the format is the next one: The first node of the linked list is white, every next node is the opposite color of the last node. For example if the square is: white -> white -> white -> black - > white - > black -> black the linked list would be 3 -> 1 -> 1 -> 2 -> null (if there are consecutive colors they sum up in the linked list as seen before). So my code is the next:
public static int[][] restorePicture (LinkedList[] linked_list)
{
boolean black = false;
int[][] Input = new int [(linked_list.length)][];
for(int k = 0; k < linked_list.length; k++)
Input[k] = new int[linked_list[k].size()];
for(int i = 0;i < linked_list.length; i++)
{
black = false;
int j = 0;
while(linked_list[i].get(j) != linked_list[i].getLast())
{
if(black == false)
{
for(int z = (int) linked_list[i].get(j); z > 0 ;z--)
Input[j++][i] = 1;
black = true;
}
if(black == true)
{
for(int x = (int) linked_list[i].get(j); x > 0 ;x--)
Input[j++][i] = 0;
black = false;
}
}
}
for(int i = 0; i < Input.length; i++)
for(int j = 0; j < Input[j].length; j++)
System.out.println(Input[i][j]);
return Input;
}