using
System;
using
System.Collections.Generic;
class
BitInteger {
bool
[] bits;
public
static
int
INTEGER_SIZE = 32;
public
BitInteger() { bits =
new
bool
[INTEGER_SIZE]; }
public
BitInteger(
int
value)
{
bits =
new
bool
[INTEGER_SIZE];
for
(
int
j = 0; j < INTEGER_SIZE; j++) {
if
(((value >> j) & 1) == 1)
bits[INTEGER_SIZE - 1 - j] =
true
;
else
bits[INTEGER_SIZE - 1 - j] =
false
;
}
}
public
BitInteger(
string
str)
{
int
len = str.Length;
int
x = INTEGER_SIZE - len;
bits =
new
bool
[INTEGER_SIZE];
int
i = 0;
for
(
int
j = x; j <= INTEGER_SIZE && i < len;
j++, i++) {
if
(str[i] ==
'1'
)
bits[j] =
true
;
else
bits[j] =
false
;
}
}
public
int
fetch(
int
k)
{
if
(bits[k])
return
1;
return
0;
}
public
void
set
(
int
k,
int
bitValue)
{
if
(bitValue == 0)
bits[k] =
false
;
else
bits[k] =
true
;
}
public
int
toInt()
{
int
n = 0;
for
(
int
i = 0; i < INTEGER_SIZE; i++) {
n = n << 1;
if
(bits[i])
n = n | 1;
}
return
n;
}
};
class
GFG {
static
int
findMissingFunc(List<BitInteger> myList,
int
column)
{
if
(column < 0)
return
0;
List<BitInteger> oddIndices
=
new
List<BitInteger>();
List<BitInteger> evenIndices
=
new
List<BitInteger>();
foreach
(BitInteger t
in
myList)
{
if
(t.fetch(column) == 0)
evenIndices.Add(t);
else
oddIndices.Add(t);
}
if
(oddIndices.Count >= evenIndices.Count)
return
(findMissingFunc(evenIndices,
column - 1))
<< 1
| 0;
else
return
(findMissingFunc(oddIndices, column - 1))
<< 1
| 1;
}
static
int
findMissing(List<BitInteger> myList)
{
return
findMissingFunc(myList,
BitInteger.INTEGER_SIZE - 1);
}
public
static
void
Main(
string
[] args)
{
List<BitInteger> a =
new
List<BitInteger>();
a.Add(
new
BitInteger(
"0000"
));
a.Add(
new
BitInteger(
"0001"
));
a.Add(
new
BitInteger(
"0010"
));
a.Add(
new
BitInteger(
"0100"
));
a.Add(
new
BitInteger(
"0101"
));
int
missing1 = findMissing(a);
Console.WriteLine(missing1);
}
}