TCS Digital Exam | DCA | Direct Capability Assessment

TCS Digital Exam Previously Asked Coding Question 

Below the details on TCS Digital Syllabus for their upcoming Drive in 2021  -22 for 7 LPA. The TCS Digital Exam will be for 1 hrs 50 mins and conducted on the TCS iON Platform, following are the sections that are asked -

The Exam will have the following sections:

  • Advance quants
  • English
  • Advance Coding 
In this article, we will be discussing some of the TCS Digital Exam Coding Questions asked in the previous recruitment teststcs digital coding questions with answers 202TCS Digital Coding Questions 2020,tcs digital coding questions with answers 2021,tcs dca coding questions 2021,tcs wings 1 dca coding questions,TCS DCA Coding Questions Java,tcs dca coding questions September 2021,tcs dca September 2021 result.

Some Previously Asked TCS Digital Coding Question with Solutions

Question 1 :  Asked In DCA Internal Exam Money Coin Difference

A Man has money coin in two different bags He visit the market to buy some items. Bag has N coins ad bags B has M Coins and bag B has M coins . The denomination at the money are given by array of element in a[] and b[] . He can buy product on by paying an amount which an even number by choosing money from both the bags.
The task here is to find the number of ways the man can buy items such that the product of money from both the bags is an even number The man has to pick one coin at least from each bag to make even number of product.
Example 1 :
Input:
3 ---Value of N
3 ---Value of M
{1,2,3} --- a[], Elements a[0] to a[N-1], Where each input elements is separated by new line
{5,6,7} --- b[], Element b[0] to b[M-1], where each input elements is separated by new line
Output :
5 --- Number of ways he can be an even product of coins
import java.util.Scanner;
public class MyClass {
    public static void main(String args[]) {
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int m = sc.nextInt();
      int[] a = new int[n];
      int[] b= new int[m];

      for(int i=0; i<n; i++)
          a[i] = sc.nextInt();

      for(int i=0; i<m; i++)
          b[i] = sc.nextInt();

     int o1 ,e1,o2, e2;
     o1 = e1 = o2 = e2 = 0;
     for(int i : a){
         if(i%2==0) e1++;
         else o1++;
     }
     for(int i : b){
         if(i%2==0) e2++;
         else o2++;
     }
     int c =0;
     for(int x : a){
         if(x%2 == 0){
             c+=m;
         }else{
             c +=e2;
         }
     }
      System.out.println(c);
    }
}
If you want solution of any questions, send me the question here codingsolution75 I will upload it soon.

TCS Digital Question 2 : Count Ordinal positions Chairs Problem

There are 26 chairs that need to be arrange for a ceremony. The chars are named from A to Z. Every chair should be arranged according to the original number of the letter in the English alphabets. Due to some misunderstanding, the chair s are randomly arranged.
Given a str, the task here is to find the number of the chair which are correctly placed as per the ordinal number off the letter as given below.
The same positions apply for both uppercase and lower case letter.
Constraints:
str = {a-z, A-Z}
Example 1:
Input
abcxyx - Value of str
Output
3 - Number of chairs that are correctly placed as per the ordinal position of the letters of the alphabats .
Explanation : here the above input a ,b,c are in correct positions 1,2,3 respectively Rest of the letter are not in correct positions.
Hence the output is 3
Example 2 :
Input
abcxyzgh - Value of string
Output
5 - Number of chair correctly placed as per ordinal position of the letter of the English alphabet.
import java.util.Scanner;
public class Myclass {
  public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	String str = sc.nextLine();
	str = str.toLowerCase();
	int c = 0;
	for(int i=1; i<=str.length(); i++) {  
		if(str.charAt(i-1)- 96 == i) {  
	    	c++;
		}
	}
    System.out.println(c);
  }
}
If you want solution of any questions, send me the question here codingsolution75 I will upload it soon.

Question 3 : Physical Training

Each student from class 1 to 10 is given a distinct number. The physical Tanning(PT) instruct
all the N students to stands in a straight line(a[]) in ascending order. But some primary class
student don't follow the instructions and start running around .There student are made to sit
aside in the ground.

The PT instructor calls out random number(R) to check if the student with the number called is in the
line or not. If the student with number R is already present in the line give the position of the
student in the line(index) if the student with number R is not present and sitting aside in the ground
give the position where this student student should join in the line.

Given N, a[], R the the task here is to find the positions of the student as per the above instruction.

Note: Position of the student in the line start from 0.

0 <= N <= 1000
0 <= RHS <= 1000
0 <= a[i] <= 1000
Example 1 :
Input
6 -> Value of N
3 -> Value of R
{1,2,3,4,7,9} -> a[] Elements a[0] to a[N-1], where each input elements is separeted by new line

Output
2
import java.util.Scanner;
public class MyClass {
	public static int getSolution(int N, int R, int[] arr) {
		int res = 0;
		for(int i=0; i<N; i++) 
			if(arr[i] == R) res = i;
		if(res==(N-1)) {
			for(int x=0; x<N; x++) {
				if(arr[x] > R) {
					res=x;
					break;
				}
			}
		}
		return res;
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int R = sc.nextInt();
		int[] arr = new int[N];
		
		for(int i=0; i<N; i++) arr[i] = sc.nextInt();
		System.out.println(getSolution(N,R,arr));
	}
}

If you want solution of any questions, send me the question here codingsolution75 I will upload it soon.

Question 4 : Palindrome Prefix

A Special palindrome is a palindrome of size N which contains most K distinct character such that any prefix of size between and N-1 is not a palindrome.
For example abba is a special palindrome with N=4 and K=2 ababa is not a special palindrome because aba is a palindrome its a prefix of ababa.
Task
Count the number of special palindrome.
Example
Assumptions
N = 3
k = 3
Approach
All possible special palindromes are aba, aca,bab,bcb,cac and cbc
Hence the answered is 6.
Input
3
3
Output
6
public class Main{
   public static long prefix_Palindrome(int N,int K){
        int M  = 1000000000+9;
        long[] dp = new long[N+1];
        dp[1] = K;
       
        for(int i=2; i<=N; i++){
             if(i%2 == 1){
                 dp[i] = ((K * dp[i-1]) % M - dp[(i+1)/2] + M )%M;
             }else{
                 dp[i] = dp[i-1];
             }
        }
        return dp[N];
    
    }
   public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      int K = sc.nextInt();

      System.out.println(prefix_Palindrome(N,K));
   }
}
If you want solution of any questions, send me the question here codingsolution75 I will upload it soon.

Next Question ...Coming Soon!...Refresh Page

Comments

Post a Comment

If you any doubts, please let me know Telegram Id: @Coding_Helperr
Instagram Id : codingsolution75

More Related

For Any Help Related to coding exams follow me on Instagram : codingsolution75

Popular Posts

WIPRO Latest Coding Questions with Solutions : 2023

EPAM Latest Coding Questions with Solutions 2023

MindTree Latest Coding Questions with Solutions

Fresco Play Hands-on Latest Solutions

TCS Wings 1 All Prerequisite

Infosys | InfytTq | Infosys Certification Exam Latest Coding Questions with Solutions

RAKUTEN Latest Coding Questions with Solutions

Cognizant

TypeScript Complete Course With Completed Hands-on