Problem 1892. LIFO Validation
Write a function to check whether a LIFO (Last In First Out) restriction on inventory is violated.
We have two input vectors In and Out, such that In(i) represents the time at which item i entered inventory and Out(i) represents the time at which item i left inventory. Write a function that determines whether LIFO restrictions were obeyed or not.
In the input data you will be guaranteed that In(i)<Out(i) for all i, but multiple items may enter or leave inventory at the same time.
For example:
In = [1;2] , Out = [3;4] violates LIFO because item 1 enters inventory first and also leaves first.
In = [1;2] , Out = [4;3] does not violate LIFO because item 1 enters inventory first and leaves last.
In = [1;2] , Out = [3;3] does not violate LIFO because the items leave at the same time.
Solution Stats
Problem Comments
Solution Comments
Show commentsProblem Recent Solvers14
Suggested Problems
-
Make the vector [1 2 3 4 5 6 7 8 9 10]
52414 Solvers
-
Find common elements in matrix rows
2711 Solvers
-
982 Solvers
-
Find and replaces spaces from a input string with *
168 Solvers
-
Sum of diagonals elements of a matrix
228 Solvers
More from this Author3
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!