Skip to content

Instantly share code, notes, and snippets.

View ghostrecog's full-sized avatar

G Umapathi ghostrecog

  • Hyderabad
View GitHub Profile
import java.util.*;
public class math {
public static void main(String []args){
Scanner sc=new Scanner(System.in);
int a=sc.nextInt();
int b=sc.nextInt();
int sum=63,total=3000;
for(int i=0;i<sum;i++){
@ghostrecog
ghostrecog / UnityInZerosAlternativeMethod
Created October 10, 2017 13:39
You are given with array, now you need to sort in such a way that all zeros should be moved to last, without changing the order of non zeroes.
import java.util.*;
public class UnityInZerosAlternativveMethod {
public static int[] unityInZeros(int[] input1)
{
int [] output=new int [input1.length];
int k=0;
for(int i=0;i<input1.length;i++){
for(int j=0;j<input1.length-1;j++){
if(input1[j]==0&&input1[j+1]!=0){
@ghostrecog
ghostrecog / FiveMultiplesInAscendingOrder
Created October 9, 2017 13:53
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.
import java.util.*;
public class Testing2 {
public static void main(String [] args){
Scanner sc=new Scanner(System.in);
int size;
size=sc.nextInt();
int [] arr=new int [size];
int sorted[]=new int[size]; //sorted array created to preserve non 5 multiples in the same order.
@ghostrecog
ghostrecog / CountTriplets
Created October 5, 2017 11:16
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.
/*
* 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.
*/
import java.io.*;
import java.util.*;
public class CandidateCode {
public static void main(String args[] ) throws Exception {
@ghostrecog
ghostrecog / ThirdLargestNumber
Created October 5, 2017 11:04
Find the third largest number in the given series.
/*
* Enter your code here. Read input from STDIN. Print your output to STDOUT.
* Your class should be named CandidateCode.
*/
import java.io.*;
import java.util.*;
public class CandidateCode {
public static void main(String args[] ) throws Exception {
@ghostrecog
ghostrecog / AddOccurrencesOfThrice
Last active October 5, 2017 10:49
In this challenge you need to check for thrice occurrences in array and sum it up.
/*
* Enter your code here. Read input from STDIN. Print your output to STDOUT.
* Your class should be named CandidateCode.
*/
import java.io.*;
import java.util.*;
public class CandidateCode {
public static void main(String args[] ) throws Exception {
@ghostrecog
ghostrecog / SecondToSmallerAndLarger
Created October 5, 2017 07:59
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.
/*
* 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.
*/
import java.io.*;
import java.util.*;
public class CandidateCode {
public static void main(String args[] ) throws Exception {
@ghostrecog
ghostrecog / LargestEven
Created October 5, 2017 07:40
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.
/*
* 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.
*/
import java.io.*;
import java.util.*;
public class CandidateCode {
public static void main(String args[] ) throws Exception {
@ghostrecog
ghostrecog / MultiplyNegativeNumbers
Created October 5, 2017 07:35
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.
/*
* 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.
*/
import java.io.*;
import java.util.*;
public class CandidateCode {
public static void main(String args[] ) throws Exception {
@ghostrecog
ghostrecog / CheckOccurrences
Created October 5, 2017 07:14
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'
/*
* 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'
*/
import java.io.*;
import java.util.*;
public class CandidateCode {
public static void main(String args[] ) throws Exception {