Beta
Max Consecutive Sum
20Kagrat
Description:
Given an integer num
, return the smallest and largest integers in a sequence of consecutive integers that sum to num
. There may be multiple sequences that work; return the longest sequence. Return null
if there are no solutions of at least 2 consecutive integers.
Example:
maxConsecutiveSum(45)
returns [1,9]
.
Notice that [14,16]
is also a valid range that adds to 45, but there is another solution with a larger number of consecutive integers.
Algorithms
Similar Kata:
Stats:
Created | Feb 22, 2021 |
Published | Feb 22, 2021 |
Warriors Trained | 120 |
Total Skips | 47 |
Total Code Submissions | 67 |
Total Times Completed | 20 |
Java Completions | 20 |
Total Stars | 6 |
% of votes with a positive feedback rating | 81% of 13 |
Total "Very Satisfied" Votes | 8 |
Total "Somewhat Satisfied" Votes | 5 |
Total "Not Satisfied" Votes | 0 |
Total Rank Assessments | 12 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 5 kyu |
Lowest Assessed Rank | 7 kyu |