Is there an easy solution to implement LIFO solution based on Java?
For instance I have the following
In (50,150,200) Out (all after all the inputs) (250,80)
The results should be something like this:
Initial - Final 200 - 200 200 - 50 150 - 80 150 - 20 50 - 50 (Remaining)
Many thanks in advance,
I thought about LinkedList:
if (outList.getFirst()>inList.getLast()){
def pieces = outList.getFirst()-inList.getLast()
valoreFinal.add(inList.getLast())
valoreInitial.add(inList.getLast())
iList.removeLast()
}
And so on, but I dont this this is the optimal solution.
Many thanks in advance,