title: Organize storage by orders algorithm
body: <p>Assumed I got big storage with a lot of products and every shelf in my storage can store maximum k elements. I also got a long list with ordering details (every order can include a variety of different products)</p>
  <p>Now I need to write an algorithm that gets order list details as an input and returns the best way to organize my storage.</p>
  <p>The algorithm must follow the terms:</p>
  <ol>
  <li>Splitting my products into shelves (subgroups size k)</li>
  <li>Products that usually come together sitting on the same shelf</li>
  </ol>
  <p>I thought about double hashmap &lt;productName,&lt;productName, counter&gt;&gt; when every product holds a different hashmap that holds all products that came with it and count the number of times that it came with it but I still find it difficult to split it to subgroups size k.
  What do you think? Is there a better way algorithm to organize it or maybe a library that doing so?</p>