title: Min number of Elements To generate all other elements using xor
body: <p>I have n integers <code>a_1, ..., a_n</code>. I want to pick the minimum number from all of them whose xor forms others. </p>
  
  <p>For example, consider <code>[1,2,3]</code>, <code>1^3=2</code> so you don't need <code>2</code> in the array. So you can remove it. To end up with <code>[1,3]</code>. So the min number of elements is <code>2</code> and they can form all  the original elements in the array by xoring any 2 of them. Would a greedy approach work here? or DP?</p>
  
  <p>Edit: To explain what I am thinking. A greedy approach I thought about was due to the fact that if <code>a^b=c</code> then <code>a^c=b</code> and <code>b^c=a</code>. First I delete all duplicates. then I would first in the beginning list all the pairs that each element can pair up with to form another element in the array. It takes <code>O(n^3)</code> for preprocessing. Then I pick the element with the least contribution and I delete it and subsequently subtract 1 from each of the other elements. I repeat this until all elements have &lt;=2 pairs. and I stop. This would also take <code>O(n^3)</code> for a total of <code>O(n^3)</code>. Does this greedy approach work? Is there a DP way to do it?</p>