Posts

Showing posts from August, 2017

War Between Even And Odd in Java

You will be given an array and you need to find odd numbers and add them, find even numbers and add them. Then compare the result, if the sum of even numbers found to be greater then print 'Even' to the output, if sum of odd number is greater than print 'odd' to the output. If sum of both found to be equal, then print 'Tied' to the output. Input 9 74 32 31 91 77 88 96 44 23 Output: Even Input: 5 2 3 4 9 6 Output: Tied

Equal to Zero in java

You will be given an array and you need to find those three elements whose sum are equal to 0.If found print True to the output else print False.Note: The length of the array should not be less than 3. Input 6 1 1 1 1 1 1 output: False Input: 6 79 60 -44 -16 22 33 Output: True  since(60+(-44)+(-16)=0)

Search Small Ones in Java

You are given with an array, now you need to find the small and second small element from the array and then show sum of small and second small output. Input 4 1 0 -1 2 Output: -1 Input: 7 1 2 3 4 5 6 7 Output: 3

Min and Max in java

Given five positive integers, find the minimum and maximum values that can be calculated by summing exactly four of the five integers. Then print the respective minimum and maximum values as a single line of two space-separated long integers. Sample Input 1 2 3 4 5 Sample Output 10 14 Explanation Our initial numbers are  ,  ,  ,  , and  . We can calculate the following sums using four of the five integers: If we sum everything except  , our sum is  . If we sum everything except  , our sum is  . If we sum everything except  , our sum is  . If we sum everything except  , our sum is  . If we sum everything except  , our sum is  . As you can see, the minimal sum is   and the maximal sum is  . Thus, we print these minimal and maximal sums as two space-separated integers on a new line. Hints:  Beware of integer overflow! Use 64-bit Integer.

Find the Biggest Difference in Array using java

You are given with an array, you need find the biggest difference in array.   For this you need find largest and smallest element in array and subtract them  you'll get the biggest difference. Input 7 29 79 17 8 4 9 97 Output: 93 Input 7 1 2 3 4 5 6 7 Output: 6

Count Couples in Java

In this program you are given with array along with number, Now you need to find pair in the array that matches with given number. Then finally display the count of pairs. Input 4 1 5 -7 1 6 Output: 2  since pairs are {1,5} and {-7,1}

Play with Array in java

In this program you are given with array, you need to print the first highest and second highest number in first place and second place respectively followed by remaining elements of array without loosing their index. Input 7 29 79 17 8 4 9 97 Output: 97 79 29 17 8 4 9 Input: 7 1 2 3 4 5 6 7 Output: 7 6 1 2 3 4 5

Find first,second and third highest numbers in an array using java

Input: 7 1 2 3 4 5 6 7 Output: 7 6 5 Input: 7 29 79 17 8 4 9 97 Output: 97 79 29