One line cpp


  • 0
    C
    class Solution {
            public:
                int missingNumber(vector<int>& nums) {
                    return nums.size()*(nums.size() + 1)/2 - accumulate(nums.begin(), nums.end(), 0);
                }
            };

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.