Java 🔥 xor 🔥 shift 🔥 100% Fast 🔥
Intuition\nOnly the sign bit matter.\n\n# Approach\n- 2 negative sign bit cancel each other using xor.\n- Early exit on 0.\n- Drag the sign bit over the whole i
# Intuition\nOnly the sign bit matter.\n\n# Approach\n- 2 negative sign bit cancel each other using xor.\n- Early exit on `0`.\n- Drag the sign bit over the whole int and set last bit.\n\n# Complexity\n- Time complexity: *`O(n)`*\n- Space complexity: *`O(1)`*\n\n# Code\n```\nclass Solution { // Vezzz\n  public int arraySign(int[] nums) {\n    int z = 0;\n    for (int v : nums)\n      if (v == 0)\n        return 0;\n      else\n        z ^= v;\n    return z >> 31 | 1;\n  }\n}\n```
['Bit Manipulation', 'Java']