Solution to PackingObjects

public class PackingObjects { public int smallestBox(int objWidth, int objLength, int[] boxWidth, int[] boxLength) { int small = Integer.MAX_VALUE; for(int k=0; k < boxWidth.length; k++) { int w = boxWidth[k]; int h = boxLength[k]; if ((objWidth <= w && objLength <= h) || (objWidth <= h && objLength <= w)){ small = Math.min(small,w*h); } } if (small == Integer.MAX_VALUE) return -1; return small; } }
Owen L. Astrachan
Last modified: Wed Jul 2 10:59:06 EDT 2003