2177. Find Three Consecutive Integers That Sum to a Given Number 發表於 2023-02-13 | 分類於 leetcode problemsolution1234567891011121314class Solution {public: vector<long long> sumOfThree(long long num) { // 1 2 3 -> 6 // 2 3 4 -> 9 // 3 4 5 -> 12 // 4 5 6 -> 15 vector<long long> ret; if(num%3!=0) return ret; long long mid = num/3; return {mid-1, mid, mid+1}; }}; analysis time complexity O(1) space complexity O(1)