C & Python || 1ms || Beats 100% || Bit manipulation
Intuition\nIf the original is 1110010101001111\nThen best value is 1110010101000111\ni.e. make the leftmost 1 in the rightmost block of 1\'s a 0.\n\nThe C and P
# Intuition\nIf the original is 1110010101001111\nThen best value is 1110010101000111\ni.e. make the leftmost 1 in the rightmost block of 1\'s a 0.\n\nThe C and Python code are basically identical (ignoring the messing around you have to do with dynamic memory in C)!\n\n# Code\n```c []\nint value(int n) {\n    if (n % 2 == 0) {\n        return -1;\n    }\n    int offset = 1;\n    while (n & (offset<<1)) {\n        offset <<= 1;\n    }\n    return n - offset;\n}\n\nint* minBitwiseArray(int* nums, int numsSize, int* returnSize) {\n    int* vals = malloc(numsSize*sizeof(int));\n    *returnSize = numsSize;\n    \n    for (int i=0; i<numsSize; ++i) {\n        vals[i] = value(nums[i]);\n    }\n    return vals;\n}\n```\n```Python []\nclass Solution:\n    def minBitwiseArray(self, nums: List[int]) -> List[int]:\n        def value(n):\n            if n % 2 == 0:\n                return -1\n            offset = 1\n            while n & (offset<<1):\n                offset <<= 1\n            return n - offset\n\n        return [value(n) for n in nums]\n```\n
['C']