Counting Increase
From ElectronicWar
| Challenge Information for Counting Increase | |
| Challenge | Counting Increase |
| Code | 5 |
| Input Example | 1,2,3,2,3,4,5,6,1,2,3,4 |
| Output Example | 5 |
| Level | 40 |
| Profit | $4000 |
| Experience | 200 to each stat |
| Description | Return the length of the longest consecutive increasing integers. |
[edit] Solution
int numCount = getInputIntCount(); int max = 0; int seq = 0; int i = 0; int next = 0; int num = getInputInt(); while (i < (numCount - 1)) { next = getInputInt(); if (num+1 == next) { seq = seq + 1; } else { if (seq > max) { max = seq; } seq = 1; } num = next; i = i + 1; } if (seq > max) { max = seq; } setOutputInt(max);

