Longest Consistent Activity Streak
Updated
Problem statement
A consistent streak is a contiguous arithmetic sequence: every adjacent difference is equal. Replace at most one element with any integer and return the greatest possible streak length.
A nonempty array of length one has streak length one; no modification is required.
Function
longestConsistentStreak(activity: int[]) → intExamples
Example 1
activity = [1,2,10,4,5]return = 5Replace 10 with 3 to obtain difference one throughout.
Example 2
activity = [1,2,3,8,9,10]return = 4One replacement can extend either arithmetic run by one.
Constraints
1 <= activity.length <= 200000.- Values fit signed 32-bit integers; replacements may be any integer.
Source note: Author-written prompt excerpt retained for source fidelity.
More Atlassian Phone Screen questions
- Merge Overlapping IntervalsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Tennis Court SchedulingPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Implement a Rate LimiterPHONE SCREEN · Seen Oct 2026
- Music Player Operation SequencePHONE SCREEN · Seen Sep 2026
- Underline Shortest Unique SubstringsPHONE SCREEN · Seen Aug 2026
- Can a Dictionary Word Be Formed from Note Letters?PHONE SCREEN · Seen Feb 2026
- Word Path Moving Only Right or DownPHONE SCREEN · Seen Feb 2026
- Ordered Badge Entry and Exit ViolationsPHONE SCREEN · Seen Aug 2025
- Two Sum with an Ordered Index PairPHONE SCREEN · Seen Aug 2025
- Can You Finish the Teleporter Board?PHONE SCREEN · Seen Jul 2025
Similar questions at other companies
- Split Array to Minimize the Largest SumNation with NaMo · PHONE SCREEN
- Trapping Rain WaterOracle · PHONE SCREENOracle interview questions
- Minimum Length After Removing Arithmetic TriplesMedia.net · PHONE SCREEN
- Select Transactions with Child-Pays-for-Parent PackagesCoinbase · PHONE SCREENCoinbase interview questions
- Longest Increasing Path in a MatrixNew Relic · PHONE SCREEN · ONSITE INTERVIEW
- Longest Increasing Subsequence With Bounded Adjacent DifferenceGoogle · PHONE SCREENGoogle interview questions
- Longest Increasing Subsequence With Bounded Adjacent DifferenceAmazon · PHONE SCREEN · ONSITE INTERVIEW
- Maximum Profit with at Most K TransactionsTekion · PHONE SCREENTekion interview questions
- Count Ordered Combination Sums with Negative ValuesPinterest · PHONE SCREENPinterest interview questions
- Minimum Matrix-Chain MultiplicationsGSA Capital · PHONE SCREEN