Join Regular Classroom : Visit ClassroomTech

TCS NQT Coding and MCQ Questions | On-Campus Placement | codewindow.in

TCS NQT
// Solution in java
import java.util.*;
import java.lang.*;
import java.io.*;

class Codewindow
{
	public static void main (String[] args) throws Exception
	{
		// your code goes here
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		while(str != null) {
		    int val = Integer.parseInt(str);
		    System.out.println(Integer.toBinaryString(val));
		    str = br.readLine();
		}
		
	}
}
// Solution in Java
import java.util.*;
import java.lang.*;
import java.io.*;

class Codewindow
{
	public static void main (String[] args) throws Exception
	{
		// your code goes here
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int num = Integer.parseInt(br.readLine());
		int[] group = new int[num];
		String[] str = br.readLine().split(" ");
		for(int i=0; i<num; i++)
		    group[i] = Integer.parseInt(str[i]);
		if(num%2 == 0) {
		    for(int i=0; i<num/2; i++)
		        System.out.print(group[i] + " ");
		    System.out.println();
		    for(int i=num/2; i<num; i++)
		        System.out.print(group[i] + " ");
		} else {
		    for(int i=0; i<=num/2; i++)
		        System.out.print(group[i] + " ");
		    System.out.println();
		    for(int i=num/2 + 1; i<num; i++)
		        System.out.print(group[i] + " ");
		}
	}
}
// Solution in Java
import java.util.*;
import java.lang.*;
import java.io.*;

class Codewindow
{
    static int gcd(int a, int b)  
    {
        while(b != 0)
        {
            if(a > b)
                a = a - b;
            else
                b = b - a;
        }
        return a;
    }
	public static void main (String[] args) throws Exception
	{
		// your code goes here
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int a = Integer.parseInt(br.readLine());
		int b = Integer.parseInt(br.readLine());
		int n = Integer.parseInt(br.readLine());
		
		int lcm = (a * b) / gcd(a, b);
		System.out.println(n * lcm);
	}
}

C QA

Mostly Asked

DS QA

Mostly Asked

DBMS QA

Mostly Asked

ML QA

Mostly Asked

// Solution will be available soon

// We are very sorry for the inconvenience caused
// Solution will be available soon

// We are very sorry for the inconvenience caused
// Solution in Java
import java.util.*;
import java.lang.*;
import java.io.*;

class Codewindow
{
	public static void main (String[] args) throws Exception
	{
		// your code goes here
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		
		long eggs = (long)Math.pow(2, n-1);
		System.out.println(eggs);
	}
}
// Solution in Java
import java.util.*;
import java.lang.*;
import java.io.*;

class Codewindow
{
	public static void main (String[] args) throws Exception
	{
		// your code goes here
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String n = br.readLine();
		String newNum = n.substring(0, 1);
		
		for(int i=1; i<n.length(); i++)
		    newNum = newNum + '0';
		System.out.println(newNum);
	}
}
// Solution in Java
import java.util.*;
import java.lang.*;
import java.io.*;

class Codewindow
{
	public static void main (String[] args) throws Exception
	{
		// your code goes here
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String[] str = br.readLine().split(" ");
		int num[] = new int[n];
		
		for(int i=0; i<str.length; i++)
		    num[i] = Integer.parseInt(str[i]);
		Arrays.sort(num);
		for(int i=0; i<num.length; i++)
		    if(num[i]%2 == 0)
		        System.out.print(num[i]*num[i] + " ");
	}
}

Also Checkout

Recent Posts
Categories
Pages