Beta

Max Consecutive Sum

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

Stats:

CreatedFeb 22, 2021
PublishedFeb 22, 2021
Warriors Trained120
Total Skips47
Total Code Submissions67
Total Times Completed20
Java Completions20
Total Stars6
% of votes with a positive feedback rating81% of 13
Total "Very Satisfied" Votes8
Total "Somewhat Satisfied" Votes5
Total "Not Satisfied" Votes0
Total Rank Assessments12
Average Assessed Rank
6 kyu
Highest Assessed Rank
5 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • Kagrat Avatar
  • ParanoidUser Avatar
Ad