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

1
2
3
4
5
6
7
8
9
10
11
class Solution {
public long[] sumOfThree(long num) {
if (num % 3 != 0) {
return new long[0];
}

long b = num / 3;
long a = b - 1, c = b + 1;
return new long[]{a, b, c};
}
}

References

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