Java8 Streams


  • 0
    G
    public class Solution {
        public int missingNumber(int[] nums) {
            int totalxor = IntStream.range(0, nums.length+1).reduce(0, (a, b) -> a^b);
            int numsxor = Arrays.stream(nums).reduce(0, (a, b) -> a^b);
            return totalxor ^ numsxor;
        }
    }
    

Log in to reply
 

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