Steps to Reproduce: 1. Give the slot size of 7. 2. Give the item of sizes 3, 4 along with the arrival and the departure dates. 3. Run the file. Throwing an exception i.e Array Index Out of Bounds for check perfect subset in optimize method. Given test case: @Test void testOptimizeBuffer1() { ByteArrayOutputStream outContent = new ByteArrayOutputStream(); System.setOut(new PrintStream(outContent)); Warehouse wh = Warehouse.getInstance(); Optimize op = new Optimize(); Slot slot2 = new Slot(7); Item item1 = new Item(3,new Day("13-Oct-2020"),new Day("20-Oct-2020")); Item item2 = new Item(4,new Day("13-Oct-2020"),new Day("20-Nov-2020")); wh.optimize(); assertEquals("The system is optimized.", outContent.toString()); }