1ms java solution without bit manipulation


  • 15
    A
    public class Solution {
    public int missingNumber(int[] nums) {
        int sum = 0, i = 0;
    
        for (; i < nums.length; i++)
            sum = sum + i - nums[i];
        
        return (sum + i);
    }
    

    }


Log in to reply
 

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