Member-only story
#JavaSolved : Bitwise One
Have the function BitwiseOne(strArr) take the array of strings stored in strArr, which will only contain two strings of equal length that represent binary numbers, and return a final binary string that performed the bitwise OR operation on both strings. A bitwise OR operation places a 0 in the new string where there are zeroes in both binary strings, otherwise it places a 1 in that spot. For example: if strArr is [“1001”, “0100”] then your program should return the string “1101”.
Examples
Input: new String[] {“100”, “000”}
Output: 100
Input: new String[] {“00011”, “01010”}
Output: 01011
import java.util.*;
import java.io.*;
class Main {
static String BitwiseOne(String[] strArr) {
String res=””;
int max_size = Integer.MIN_VALUE;
for (int i=0; i<strArr.length; i++){
max_size = Math.max(max_size, (int)strArr[i].length());
strArr[i] = reverse(strArr[i]);
}
for (int i=0; i<strArr.length;i++){
String m=””;
for (int j=0; j<max_size-strArr[i].length(); j++)