One line Java solution using Lambda expressions.


  • 0
    M
    public class Solution {
        public int singleNumber(int[] nums) {
            return Arrays.stream(nums).reduce(0, (x, y) -> x ^ y);
        }
    }
    

Log in to reply
 

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