khansuhel / BitDifferenceSum

Print the sum of the bit difference

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

BitDifferenceSum

Prints the sum of the bit difference

Run App.java inside com.uber.poc

This will take in a String input in form of a comma-seperated String and then prints the sum of bit differences in the below mentioned fashion:

Input: arr[] = {1, 2} Output: 4 All pairs in array are (1, 1), (1, 2) (2, 1), (2, 2) Sum of bit differences = 0 + 2 + 2 + 0 = 4

Input: arr[] = {1, 3, 5} Output: 8 All pairs in array are (1, 1), (1, 3), (1, 5) (3, 1), (3, 3) (3, 5), (5, 1), (5, 3), (5, 5) Sum of bit differences = 0 + 1 + 1 + 1 + 0 + 2 + 1 + 2 + 0 = 8

About

Print the sum of the bit difference


Languages

Language:Java 100.0%