You are attempting to assemble a wardrobe, but you have misplaced the instructions. The wardrobe has several holes, each of which is designed to accommodate a bolt of a specific size. A hole with size D should be matched with a bolt of size D. However, bolts with sizes D-1 and D+1 will also fit. Since you don't have the instructions, you decide to do the following: For each bolt, you will randomly choose an available hole in which the bolt will fit, and screw the bolt into that hole. If the bolt cannot fit into any of the available holes, you will skip it and move on to the next one.
You are given a int[] bolts containing the sizes of the bolts. For each element in bolts, there is a corresponding hole with the same size. Return the maximum number of unused holes that can remain at the end of this process.
|