Cody

# Problem 1892. LIFO Validation

Solution 378991

Submitted on 6 Jan 2014 by Jean
• Size: 20
• This is the leading solution.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
1

ans = 1

2   Pass
%% assert(isequal(true,isLIFO([1;2],[4;3]))); 2

ans = 2

3   Pass
%% assert(isequal(false,isLIFO([1;2],[3;4]))); 3

ans = 3

4   Pass
%% for i=1:100 In = randi(20,100,1); Out = randi(20,100,1); valid = In<Out; In=In(valid); Out=Out(valid); TF=true; for k=1:numel(In)-1 for l=k+1:numel(In) if (In(k)<In(l)) && (Out(k) < Out(l)) TF = false; end end end assert(isequal(TF,isLIFO(In,Out))); end 4

ans = 4

5   Pass
%% assert(isequal(true,isLIFO([1;2],[3;3]))); 5

ans = 5

6   Pass
%% assert(isequal(true,isLIFO([2;2],[4;3]))); 6

ans = 6

7   Pass
%% assert(isequal(true,isLIFO([2;2],[7;6]))); 7

ans = 7

8   Pass
%% assert(isequal(false,isLIFO([2;1],[4;3])));

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!