[1,3,3,4,2,3,3,2,2,2]

and the rectangle described by the two parameters (height first, then width)

3 2

your code should return the array:

[1,2,5]

public class fun1 { public static void main(String [] args) { int [] shape = {1,3,3,4,2,3,3,2,2,2}; int [] result = fit(shape,3,2); System.out.println(Arrays.toString(result)); } public static int [] fit(int [] shape, int height, int width) { int length = shape.length; int widthCounter = 0; int i = 0; int k = 0; int countCount = 0; for (i = 0; i < shape.length; i++){ if (shape[i] >= height){ widthCounter++; if (widthCounter == width){ k++; widthCounter = 0; } } } int [] freshArray = new int[k]; System.out.println("number of elements built: " + k); return freshArray; } }

Now I feel as though I am very close but using arraylists or hashmaps are forbidden, and so I am having trouble figuring out a way to store the index position. I think I need to keep a count after:

if (shape[i] >= height){

but I just can't figure out the syntax. I also need to set i = to the value that is >= height so I can start i counting again after finding a box fit, I believe that covers it for logic, any syntax help would be greatly appreciated.