title: optimised cost to travel and collect units form factories
body: <p><strong>Problem statement</strong>
  there are 'n' factories, situated at arr[i]. The entry is at  '0' and the exit id at 'exit-pos' . The moving time form one place to another is the distance between the two.</p>
  <p>Each factory takes 'processing' time (same for all) to process. You have to start from '0' , exit from 'exit-pos' .</p>
  <p>Also you have to produce 'n' units, each factory can produce 1 unit only. Along the path you need to visit each factory and give the order to produce. Then it will take ' processing' time to produce it. you can wait that time for the unit to produce and move ahead. Or you can visit other factories to give them order. latter you need to visit the factory again to pick the order.</p>
  <p>Time taken to travel is the distance between the two places.</p>
  <p><strong>Question</strong>: You need to tell the minimum time taken to produce 'n' units and collect them also. Your journey starts at '0' and ends at a 'end-pos'.</p>
  <p><strong>Input:</strong></p>
  <pre><code>number of units required to produce = number of factories = n
  the location of factories in a array = arr
  the exit position =  ext-pos
  the processing time at each unit (it is same for each factory) = processing-time.
  </code></pre>
  <p><strong>my approach</strong>
  I had this question during a test. Test is submitted but unfortunately no answers were given. During the test, I tried to used a recursive approach. It considered the 'items-collected', 'time', 'factory - position'. It failed. It got into a time loop.</p>
  <p>Any suggestion/ question is there regarding question's clarity feel free to comment.
  Thanks</p>
  <p>update: 0 &lt; arrr[i] (factory time) &lt; exiPos</p>