C++ easy understand


  • 0
    B
    class Solution {
    public:
        int missingNumber(vector<int>& nums) {
            
            const int len=nums.size();
            int result=len;
            for(int i=0;i<len;i++){
                result=result^nums[i]^i;
            }
           
            return result;
        }
    };

Log in to reply
 

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