TCS DCA Coding Questions 30 September 2021 | TCS Ninja (TCS NQT) to TCS Digital - PrepInstaTechBlog

TCS DCA Coding Questions 2021

In this blog post, PrepInstaTechBlog provides TCS DCA Coding Questions asked in the TCS Elevate Wings 1 Direct Capability Assessment (TCS DCA) conducted on 30th September 2021. This information is helpful to you in passing the Digital Capability Assessment Exam (TCS DCA Exam) and promotes you to Digital Cadre in TCS in September 2021.

Don't miss it! TCS DCA Questions 28th September 2021
Don't miss it! TCS DCA Questions 29th September 2021
Don't miss it! TCS DCA Questions 27th September 2021


TCS DCA Coding Questions 30 September 2021

TCS DCA Coding Questions 30th September 2021 - 1:

In the game of scrabble, in order to avoid over-usage of the same letters in any word, Mario is trying to calculate if a letter appears more than three times in any word and wants to discard such words. In order to assist Mario, write a program to identify the number of times the most repeating letter would appear within any word. If the output number is more than three, Mario shall discard such words and choose another word for the game.

Example 1: trumpet –Value of String input

Output:

2-Highest number of repeating letters in the word “trumpet”

Explanation: In the word “trumpet”, the highest repeating letter is ‘t’ repeated 2 times

Example 2:

Input: reiterate – Value of String

Output: 3- The highest number of repeating letters in the word reiterate.
Explanation: The word “reiterate” has 3 occurrences of the letter the rest of the letters appear only once

Constraints:

str = (a-z)

The input format:
The candidate has to write the code to accept 1 input.
Accept a single string value (lowercase 301016 alphabets).

The output format:
• The output should be a positive integer number (check the output in Example 1 and Example 2).
• The system does not allow any kind of hard-coded input value/values.
• The written program code by the candidate will be verified against the inputs which are supplied from the system.

TCS DCA Coding Questions Answers - 1:

Solution:

TCS DCA Coding Questions C Language

// Solution by PrepInstaTechBlog

#include <stdio.h>
#include <string.h>
int main ()
{
  char str[100];
  char freq[256] ={0};
  scanf("%s",str);
  int i, max;
  int count = 0;
  max=0;
  
  for(int i=0;str[i]!='\0';i++)
  {
     freq[str[i]]++;
  }
  for(int i=0;str[i]!='\0';i++)
  {
     if(freq[str[i]]>max)
     {
         max =freq[str[i]];
     }
  }
  printf("%d",max);
  
}

Write your solution in the comment section in case you have the solution in any other programming language.

TCS DCA Coding Questions 30th September 2021 - 2:

In an amusement park ticket booking system, reservations are stored in batches of user purchase as continuous ascending and nonrepeating reservation IDs. Reservation IDs are positive integers, set between 1 to 10000 and reset to 1 once 10000 is reached. Occasionally, it has been observed that for batches of booking between 3 and a maximum of 25 tickets by any user, one of the reservation IDs is omitted in the system. While a permanent fix is being provided by the software vendor, the task is to develop a program to identify the omitted reservation ID from such impacted batches. .

The tickets are always sorted in ascending order.

Example 1:

Input:

7— Value of N
(1,2,4,5,6,7,8) –ar[], Elements ar[0] to ar[N-1], where each input element is separated by a new line

Output : 3

Explanation:
In the Array arl], numbers are sorted in ascending numbers from 1 to 8, however, 3 is omitted.
Hence, the output is 3.


Example 2:

Input

5 — Value of N

(23, 24, 25, 26, 28) — ar[], Elements ar[0] to ar[N] where input each element is separated by a new line.

Output:

27 — Number 27 is omitted in the Array of sorted numbers.

Explanation:
In the Array [ar], numbers are sorted in ascending numbers from 23 to 28, however, 27 is omitted.
Hence, the output is 27.

Input format:

The candidate has to write the code to accept 2 input(s).

First Input-Accept value for N (positive integer)

Second Input – Accept N number of positive integer values(ar[]), where each value is separated by a new line.


Output format:

• The output should be a positive integer number (check the output in Example 1 and Example 2).
• Additional messages in the output will cause the failure of test cases.

Instructions:
• The system does not allow any kind of hardcoded input value/values, The written program code by the candidate will be verified against the inputs which are supplied from the system

TCS DCA Coding Questions Answers - 2:

Solution:

TCS DCA Coding Questions JAVA

// Solution by PrepInstaTechBlog

import java.util.Arrays;
import java.util.Scanner;

class PrepInstaTechBlog
{
	public static void main(String args[])
	{
	Scanner sc=new Scanner(System.in); 
	int num=sc.nextInt();
	int[] a=new int[num]; 
	int c=0;

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

	}

	Arrays.sort(a);

	for(int i=0;i<a.length-1;i++)
	{
		if(a[i+1]-a[i]!=1)
		{
			c=a[i+1]-1;
			break;

		}

	} 
	System.out.println(c);
	
}
}

TCS DCA Coding Questions Answers - 2:

Solution:

TCS DCA Coding Questions Python

num = int(input())
l = []
res = int(input())

for i in range(num - 1):
    k = int(input())
    res += 1

    if res != k:
        print(res)
        break

Don't miss it! TCS DCA Exam Questions and Answers | TCS NQT to TCS Digital

 

Let us know other TCS DCA Exam Questions that you know which were previously asked on our mail contactus.techblog@gmail.com. Help others to clear TCS DCA Exam. You can get more questions using tcs dca mock test for TCS DCA September 2021.

Thanks for reading this TCS DCA Questions 30th September 2021 and the Answers blog. Please share this article with your friends and colleagues as much as possible and help them to clear TCS DCA Exam. 

You can write to us your questions or feedback on our e-mail. Keep visiting, Stay updated with the latest trends on our blog.


Note: This information is gathered from public blogs and available on the Internet for free. We do not represent or affiliated with any company or organization. This is not an official blog of TCS. The reader should verify all the information before taking any action.

No comments:

Powered by Blogger.