TopCoder problem "CompetitionStatistics" used in SRM 259 (Division II Level One)



Problem Statement

    

The longest consecutive rating increase streak is a very important statistic in any competition. You are to calculate this statistic for a certain player.

You will be given a int[] ratingChanges containing the rating changes of the player in chronological order. Your method should return the maximum number of consecutive competitions with positive rating changes. Note that 0 is not a positive number.

 

Definition

    
Class:CompetitionStatistics
Method:consecutiveGrowth
Parameters:int[]
Returns:int
Method signature:int consecutiveGrowth(int[] ratingChanges)
(be sure your method is public)
    
 

Constraints

-ratingChanges will contain between 1 and 50 elements, inclusive.
-Each element of ratingChanges will be between -1000 and 1000, inclusive.
 

Examples

0)
    
{30, 5, -5, 3, 3, 1}
Returns: 3
The player raises rating two times, afterwards reduces it once and finally raises it three times in a row.
1)
    
{-1, -5, -9}
Returns: 0
No rating changes are positive.
2)
    
{12, 0, 15, 73}
Returns: 2
3)
    
{12, 1, 15, 73}
Returns: 4
4)
    
{-6, 13, 15, -11, 12, 12, 33, 12, -1}
Returns: 4

Problem url:

http://www.topcoder.com/stat?c=problem_statement&pm=4716

Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=8012&pm=4716

Writer:

Andrew_Lazarev

Testers:

PabloGilberto , lbackstrom , brett1479 , Olexiy

Problem categories:

Brute Force