Counting Increase
From Hack Wars Wiki
Outdated and challenge answer, should be deleted. - aoi
| Challenge Information for Counting Increase | |
| Challenge | Counting Increase |
| Code | 5 |
| Input Example | 1,2,3,2,3,4,5,6,1,2,3,4 (Int) |
| Output Example | 5 (Int) |
| Level | 40 |
| Profit | $4,000 |
| Experience | 200 to each stat |
| Description | Return the length of the longest consecutive increasing integers. |
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++; } if (seq > max) { max = seq; } setOutputInt(max); |
