Cody

# Problem 730. How many trades represent all the profit?

Solution 368605

Submitted on 11 Dec 2013 by Robert
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

trades = 1 3 -4 2 -1 2 3 profit = 6 nums = 0 trades = 0 nums = 3 trades = 1 maxs = 2 7 x = 1 -4 2 -1 2 3 nums = 6 trades = 2 maxs = 6 x = 1 -4 2 -1 2 y = 2

2   Pass

trades = 1 2 3 -5 profit = 1 nums = 0 trades = 0 nums = 3 trades = 1 maxs = 3 x = 1 2 -5 y = 1

3   Pass

trades = 1 2 3 4 5 6 profit = 21 nums = 0 trades = 0 nums = 6 trades = 1 maxs = 6 x = 1 2 3 4 5 nums = 11 trades = 2 maxs = 5 x = 1 2 3 4 nums = 15 trades = 3 maxs = 4 x = 1 2 3 nums = 18 trades = 4 maxs = 3 x = 1 2 nums = 20 trades = 5 maxs = 2 x = 1 nums = 21 trades = 6 maxs = 1 x = Empty matrix: 1-by-0 y = 6

4   Pass
%% trades = [-2 3 -4 5 -6 1 2 3 4 5] y_correct = 3; assert(isequal(trade_profit(trades),y_correct))

trades = -2 3 -4 5 -6 1 2 3 4 5 profit = 11 nums = 0 trades = 0 nums = 5 trades = 1 maxs = 4 10 x = -2 3 -4 -6 1 2 3 4 5 nums = 10 trades = 2 maxs = 9 x = -2 3 -4 -6 1 2 3 4 nums = 14 trades = 3 maxs = 8 x = -2 3 -4 -6 1 2 3 y = 3

### Community Treasure Hunt

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

Start Hunting!