Input: arr[] = {541, 763, 321, 716, 143}
Output: Difference = 631, Count of operations = 6
Explanation:
Operation 1: Left shift the digits of arr[1] (= 763). Therefore, arr[1] becomes 637.
Operation 2: Left shift the digits of arr[1] (= 637). Therefore, arr[1] becomes 376.
Operation 3: Left shift the digits of arr[2] (= 321). Therefore, arr[2] becomes 213.
Operation 4: Left shift the digits of arr[2] (= 213). Therefore, arr[2] becomes 132.
Operation 5: Left shift the digits of arr[3] (= 716). Therefore, arr[3] becomes 167.
Operation 6: Left shift the digits of arr[4] (= 143). Therefore, arr[4] becomes 431.
Therefore, Sum of prime array elements = 541 + 167 + 431 = 1139.
Therefore, sum of non-prime array elements = 376 + 132 = 508.
Therefore, difference = 1139 - 508 = 631.
Input: {396, 361, 359, 496, 780}
Output: Difference = 236, Count of operations = 4
Explanation:
Operation 1: Left shift the digits of arr[1] (= 361). Therefore, arr[1] becomes 613.
Operation 2: Left shift the digits of arr[2] (= 359). Therefore, arr[2] becomes 593.
Operation 3: Left shift the digits of arr[4] (= 780). Therefore, arr[4] becomes 807.
Operation 4: Left shift the digits of arr[4] (= 807). Therefore, arr[4] becomes 078.
Therefore, required difference = 613 + 593 – 496 - 78 – 396 = 236.
for more details!