using
System;
class
GFG
{
static
String strBitwiseOR(String[] arr,
int
n)
{
String res=
""
;
int
max_size =
int
.MinValue;
for
(
int
i = 0; i < n; i++)
{
max_size = Math.Max(max_size, (
int
)arr[i].Length);
arr[i] = reverse(arr[i]);
}
for
(
int
i = 0; i < n; i++)
{
String s=
""
;
for
(
int
j = 0; j < max_size - arr[i].Length; j++)
s +=
'0'
;
arr[i] = arr[i] + s;
}
for
(
int
i = 0; i < max_size; i++)
{
int
curr_bit = 0;
for
(
int
j = 0; j < n; j++)
curr_bit = curr_bit | (arr[j][i] -
'0'
);
res += (
char
)(curr_bit +
'0'
);
}
res = reverse(res);
return
res;
}
static
String reverse(String input)
{
char
[] temparray = input.ToCharArray();
int
left, right = 0;
right = temparray.Length - 1;
for
(left = 0; left < right; left++, right--)
{
char
temp = temparray[left];
temparray[left] = temparray[right];
temparray[right] = temp;
}
return
String.Join(
""
,temparray);
}
public
static
void
Main(String[] args)
{
String []arr = {
"10"
,
"11"
,
"1000001"
};
int
n = arr.Length;
Console.WriteLine(strBitwiseOR(arr, n));
}
}