Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

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 sequence with the largest number of consecutive integers. 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.