XOR Strings 2

  • + 0 comments

    bruh what happend to hankerrank it feels like a cheap website it wasn't like this before the code isn't working

    import java.io.; import java.util.;

    public class Solution {

    public static void main(String[] args) {
        /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        String str2 = sc.next();
    
        String result = xor(str, str2);
        System.out.println(result);
    
    }
    
    public static String xor(String str, String str2)
    {
        StringBuilder s = new StringBuilder();
        for(int i = 0; i <= str.length() - 1; i+=1)
        {
            int num1 = str.charAt(i) - '0';
            int num2 = str2.charAt(i) - '0';
            s.append(num1 ^ num2);
        }
        return s.toString();
    }
    

    }