Ad

Given an integer num, return an array consisting of positive consecutive integers that sum to num. There may be multiple sequences that work; return the sequence with the largest number of consecutive integers. Return an empty array if there are no solutions.

Example:

maxConsecutiveSum(45) returns [1,2,3,4,5,6,7,8,9].

Notice that [14,15,16] also add to 45 but there is a solution that has more numbers in it.

public class maxConsecutiveSum{
  public static int[] maxConsecutiveSum(int num){
    //code goes here
    return [];
  }
}