Elixir - Bit manipulation
Complexity

Time complexity:
O(n)


Space complexity:
O(n)

Code
# Complexity
- Time complexity:
O(n)

- Space complexity:
O(n)

# Code
```elixir []
defmodule Solution do
  @spec min_bitwise_array(nums :: [integer]) :: [integer]
  def min_bitwise_array(nums) do
    for n <- nums do
      cond do
        n == 2 -> -1
        Bitwise.band(n, n + 1) == 0 -> remove_msb(n)
        true -> 
          least_zero_bit_pos = find_least_zero_bit_pos(n, 1)
          mask = Bitwise.bsl(1, least_zero_bit_pos - 2)
          Bitwise.bxor(n, mask)
      end
    end
  end

  defp no_of_bits(n) do 
    bits = :math.log2(n)
    ceiled_bits = ceil(bits)
    if bits == ceiled_bits, do: ceiled_bits + 1, else: ceiled_bits 
  end

  defp remove_msb(n) do
    no_of_bits = no_of_bits(n)
    mask = Bitwise.bsl(1, no_of_bits - 1) - 1
    Bitwise.band(n, mask)
  end 

  defp find_least_zero_bit_pos(n, pos) do
    if Bitwise.band(n, 1) == 0, do: pos, else: find_least_zero_bit_pos(Bitwise.bsr(n, 1), pos + 1)
  end
end
```
['Elixir']