Class Solution

  • All Implemented Interfaces:

    
    public final class Solution
    
                        

    2177 - Find Three Consecutive Integers That Sum to a Given Number.

    Medium

    Given an integer num, return three consecutive integers (as a sorted array) that sum to num. If num cannot be expressed as the sum of three consecutive integers, return an empty array.

    Example 1:

    Input: num = 33

    Output: 10,11,12

    Explanation: 33 can be expressed as 10 + 11 + 12 = 33.

    10, 11, 12 are 3 consecutive integers, so we return 10, 11, 12.

    Example 2:

    Input: num = 4

    Output: []

    Explanation: There is no way to express 4 as the sum of 3 consecutive integers.

    Constraints:

    • <code>0 <= num <= 10<sup>15</sup></code>

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
      Solution()
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      final LongArray sumOfThree(Long num)
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait