Longest Rising Streak
Easy About 10 min Free, no account needed
Measure a consecutive telemetry climb without rescanning every possible starting point.
The brief
A sensor records readings in order. Return the length of its longest contiguous, strictly increasing run. Equal neighbors break a run. You cannot skip a reading.
Solve([1, 3, 2, 4, 5]) returns 3, for [2, 4, 5]. This is a consecutive streak, not an increasing subsequence.
An empty input returns 0. There are at most 200,000 readings, each a signed 32-bit integer. Do not modify the input. The large test rejects rescanning forward from every start.
Starter code
using System;
public class Solution
{
public int Solve(int[] readings)
{
// TODO: implement the contract without changing the input.
throw new NotImplementedException();
}
}How it is graded
Visible examples help you iterate. Hidden tests then cover edge cases and larger inputs, and every test reports server-measured time and allocated bytes.
What it practices
- Sliding window
- Grow and shrink a contiguous range while maintaining its state incrementally.
Related katas
- Max Sum Subarray of Size K Easy Free The biggest sum any window of exactly k elements can reach.
- Find All Anagram Start Indices Medium Free Every position where an anagram of the pattern begins.
- Fruit Into Baskets Medium Free Longest stretch of trees using at most two fruit types.
- Longest Repeating Character Replacement Medium Free Longest uniform run you can create with k character replacements.