Java ^ operation


  • 0
    K

    String s = Integer.toString(num, 2);

    	for (int i = 0; i < s.length(); i++) {
    
    		int n = 1 << i;
    
    		num = num ^ n;
    
    	}
    	
    	return num;

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.