Posts

Showing posts from October, 2017

Sort 5 multiples in ascending order using java

For this challenge, you will be given an array and you are asked to find multiples of 5 in the given array, sort and put them first in the array. Rest all the elements will preserve their orders.  Input Format  -  you will be taking a number as an input from STDIN which tells about the length of the array. On another line, array elements should be there with single space between them.  Output Format  -  print the required array to the STDOUT.  Sample Test Case:   Sample Input: - 6 9 14 15 10 8 5 Sample Output  -  5 10 15 9 14 8

Count triplet in java

Task  -  You will be given an array and a number and you need to find the number of triplet in the array whose sum is equal to given number in the input.  Input Format  -  you will be taking a number as an input from STDIN which tells about the length of the array. On another line, array elements should be there with single space between them. Next line should have a integer value.  Output Format  -  you need to print the number of triplet of integers in the array whose sum is equal to the given integer.  Sample Test Case:   Sample Input: - 4 2 5 7 -1 6  Sample Output  -  1 Explanation:   There is 1 triplet with sum 6 which is (2, 5, -1). So, output is 1.

Third Largest in java.

You will be given 4 numbers one on each line and you are asked to find the second largest number and print them to the STDOUT .  Input Format  -  You will take 4 integers as input from STDIN.  Output Format  -  print your result which will be the integer only to the STDOUT.  Sample Test Case:   Sample Input: - 234 213 666 879  Sample Output  -  234

Add occurrences of thrice in java

In this challenge you need to check for thrice occurrences in array and sum it up. Input Format  -  you will be taking a number as an input from STDIN which tells about the length of the array. On another line, array elements should be there with single space between them.  Output Format  -  You need to print the sum of the numbers occurring Thrice.  Sample Test Case:   Sample Input: - 12 9 8 7 7 8 6 5 4 7 8 1 2  Sample Output  -  15 Explanation:   elements 8 and 7 occurring Thrice and their sum is 15.

Second to smaller and larger in java

You will be given an array and you need to find the second largest and second smallest numbers and add them.  Note:  the length of the array should not be less than 2.  Input Format  -  you will be taking a number as an input from stdin which tells about the length of the array. On another line, array elements should be there with single space between them.  Output Format  -  you need to print the addition of second largest and second smallest elements to the stdout.  Sample Test Case:   Sample Input: - 7 48 77 7 11 49 99 78 Sample Output  -  89

Largest Even in java

Task - For this challenge, you will be given an array and you are asked to find the largest even number and print it to the STDOUT.  Input Format  -  you will be taking a number as an input from STDIN which tells about the length of the array. On another line, array elements should be there with single space between them.  Output Format  -  print the largest even number to the STDOUT.  Sample Test Case:   Sample Input: - 6 78 92 44 63 71 97 Sample Output  -  92  Explanation:   In the given array, 78, 92 and 44 are the even numbers and we need to find the largest even number which is 92.

Multiply Negative numbers in java

For this challenge, you will be given an array and you are asked to count how many numbers are negative and multiply them and print the output to the STDOUT.  Input Format  -  you will be taking a number as an input from STDIN which tells about the length of the array. On another line, array elements should be there with single space between them.  Output Format  -  print the multiplication to the STDOUT.  Sample Test Case:   Sample Input: - 7 -8 -7 6 0 7 -1 6 Sample Output  -  -56  Explanation:   There are three negative numbers present in the array and their multiplication comes out to be -56.

Check Occurrences in java

You will be given an array and you need to find the whether there is any element occurring thrice. If yes, then print 'True' else print 'False'  Input Format  -  You will be taking a number as an input from STDIN which tells about the length of the array. On another line, array elements should be there with single space between them.  Output Format  -  You need to print the Boolean value.  Sample Test Case:   Sample Input: - 12 9 8 7 7 8 6 5 4 7 8 1 2  Sample Output  -  True  Explanation:   Elements 8 and 7 occurring Thrice and hence printing 'True'.

Second Odd Largest in java

You will be given an array and you need to find the second largest odd number and print it to the STDOUT.  Input Format  -  you will be taking a number as an input from STDIN which tells about the length of the array. On another line, array elements should be there with single space between them.  Output Format  -  you need to print the second largest odd number to the STDOUT.  Sample Test Case:   Sample Input: - 7  25 26 7 8 10 11 79  Sample Output  -  25 

Squaring Every Index in java

You will be given an array and you need to square the elements of the array, add them and print them to the stdout.  Input Format  -  you will be taking a number as an input from stdin which tells about the length of the array. On another line, array elements should be there with single space between them.  Output Format  -  You need to print the sum of the numbers.  Sample Test Case:   Sample Input: - 12  9 8 7 7 8 6 5 4 6 5 1 2  Sample Output  -  450 

Second Largest Even in java

For this challenge, you will be given an array and you are asked to find the second largest even number and print it to the stdout.  Input Format  -  you will be taking a number as an input from stdin which tells about the length of the array. On another line, array elements should be there with single space between them.  Output Format  -  print the second largest even number to the stdout.  Sample Test Case:   Sample Input: - 6 78 92 44 63 71 97 Sample Output  -  78 

Leaders in Java

  Write a program to print all the LEADERS in the array. An element is leader if it is greater than all the elements to its right side. And the rightmost element is always a leader. For example int the array {16, 17, 4, 3, 5, 2}, leaders are 17, 5 and 2. Sample Test Case:  Sample Input:- 6 16 17 4 3 5 2 Sample Output -  17 5 2 

Finding Reverse in java

Task  -  For this challenge, you will be given an integer and an array and you are asked to find the reverse of the number in the array.  Input Format  -  you will be taking a number as an input from stdin which tells about the length of the array. On another line, array elements should be there with single space between them. Next line, there is an integer whose reverse need to be found.  Output Format  -  print 'True' if the reverse of the number is present in the array otherwise return 'False'.  Sample Test Case:   Sample Input: - 6 78 92 44 63 71 97 29 Sample Output  -  True  Explanation:   Given integer is 29 and the reverse of the number is 92 and it is present in the array. Hence, print 'True'.

Count In Range and Specific in java

Task  -  You will be given an array and a range and you need to count how many array elements lies in that range and not divisible by 3 and 5.  Input Format  -  You will take an integer as input from STDIN which represent the length of the array and on another line array elements will be there separated by single space. Another line will have the starting point of the range and end point separated by space.  Output Format  -  print the count to the STDOUT.  Sample Test Case:   Sample Input: - 6 16 17 4 3 5 2 2 10 Sample Output  -  2

Discard Specific Content in java

For this challenge, you will be given an array and you are  * asked to find multiples of 5 and 10 both in the given array,  * remove them from the array. Rest all the elements will  * preserve their orders.  *  * Input Format - you will be taking a number as an input from  * stdin which tells about the length of the array. On another line,  * array elements should be there with single space between them.  * Output Format - print the required array to the stdout.   Sample Test Case:   Sample Input:- 7 10 20 15 2 4 7 8 Sample Output - 15 2 4 7 8 Input: 7 10 20 15 2 4 7 8 Output: 15 2 4 7 8