Home Get Hired TCS NQT Coding Questions with Solutions and Tips for Freshers 2025

TCS NQT Table of content:
Arrow Btn

TCS NQT Coding Questions with Solutions and Tips for Freshers 2025

TCS NQT Coding Questions with Solutions and Tips for Freshers 2025

The TCS National Qualifier Test (NQT) is a highly sought-after examination for freshers aiming to secure a position at Tata Consultancy Services (TCS). Among its sections, the Coding Ability segment tests problem-solving skills and proficiency in programming languages like C, C++, Java, Python, or Perl. 

This section plays a vital role in assessing candidates' aptitude for software development and coding challenges in real-world scenarios. This article offers an overview of TCS NQT coding questions, previous year papers, and preparation strategies to help freshers excel in this section.

Key Topics for TCS NQT Coding Section

  1. Programming Basics
    • Data types, loops, and conditions.
    • Functions and recursion.
  2. Data Structures
    • Arrays, linked lists, stacks, and queues.
    • Binary trees and graphs.
  3. Algorithms
    • Sorting and searching algorithms.
    • Dynamic programming.
  4. Problem-Solving
    • Debugging and code optimisation.
    • Real-world coding scenarios.

TCS NQT Coding Test Pattern

The coding section typically includes one or two questions that assess:

  • Algorithmic thinking.
  • Optimisation techniques.
  • Application of programming concepts.

Feature

Details

Question Types

Debugging code and solving algorithm-based problems.

Languages Supported

C, C++, Java, Python, Perl.

Time Limit

30–60 minutes, depending on the problem complexity.

Difficulty Level

Moderate to advanced.

Top 5 TCS NQT Coding Questions with Answers

Problem Statement 1

Alice challenged Bob to write the same word as his on a typewriter. Both are kids and are making some mistakes in typing and are making use of the ‘#’ key on a typewriter to delete the last character printed on it. An empty text remains empty even after backspaces. 

Input Format

The first line contains a string typed by Bob.

The second line contains a string typed by Alice.

Output Format

The first line contains ‘YES’ if Alice is able to print the exact words as Bob, otherwise ‘NO’.

Constraints

1 <= Bob.length

Alice.length <= 100000

Bob and Alice only contain lowercase letters and '#' characters.

Solution C++

Solution Java

Solution Python 

Problem Statement 2

You are provided with a 2D array(N*M). Your task is to create an ArrayList of Node objects, where each row of the 2D array corresponds to one entry in the ArrayList. After that, a doubly-linked list is constructed, arranging nodes first by even indices from the ArrayList, followed by the odd indices.

Input Format

The first line contains an integer N, representing the size of the array row.

The second line contains an integer M, representing the size of array col.

The third line contains an array.

Output Format

return the linked list

Constraints

1 <= N < 10^2

1 <= M < 10^2

Solution C++

Solution Java

Solution Python 

Problem Statement 3

Sid is reading a paragraph of a story and notices N different sentences. He's curious to know which sentence is the longest. Help Sid find the length of the longest sentence in the story. Sentences are separated by a comma(,),no other symbols are used except comma.

Input Format

The first line of input contains a string where sentences are separated by commas ( ,) 

Output Format

Display a single integer, that denotes the length of the longest sentence.

Constraints

 1<=N<=20

Solution C++

Solution Java

Solution Python

Problem Statement 4

A sequence of positive integers is called "great" for a number X if we can divide it into pairs such that, for each pair, multiplying the first number by X equals the second number. More formally, a sequence A of size N is "great" for X if N is even and there exists a permutation P of size N such that for each i (1 ≤ i ≤ (N/2)), we can rearrange it so that for every pair (Ai, Aj), we have ( Ai * x = Aj ).

Ram has a sequence A and a number X. Help Ram make the sequence "great" by determining the minimum number of positive integers that should be added to the sequence A so that it becomes "great" for the number X.

Input Format

The first line of input contains two integers N, X representing the size of the sequence and the integer X respectively.

The next line of input contains N space-seperated integers a1,a2,……an, representing the elements of the sequence A.

Output Format

Print a single integer representing the minimum number of integers that need to be appended to the end of list A in order to make it a great sequence for the number X.

Constraints

1≤Ai≤10^6

1≤N≤2*10^6

2≤X≤10^6

Solution Python

Solution C++

Solution Java

Problem Statement 5

Assert whether the given string has all the letters of the English alphabet or not.

If yes return "True" else return "False".

Assume the string contains nothing but lowercase English letters.

Input Format

The string to be checked.

Output Format

Display "True" if all the letters in English alphabets are present else display "False".

Note: Output is case-sensitive.

Constraints

1<=|S|<=1e^5

Solution C++

Solution Java

Solution Python

Are you looking for coding assessment questions related to job placement? Click here to access coding practice sessions from moderate to challenging levels.

Tips to Ace TCS NQT Coding Section

  1. Practice Previous Year Questions
    Familiarise yourself with typical problems using TCS NQT previous papers.
  2. Master Fundamentals
    Strengthen your understanding of syntax and basic constructs in your preferred language.
  3. Improve Speed and Accuracy
    Use online coding platforms like HackerRank or LeetCode to practice under timed conditions.
  4. Debugging Skills
    Learn to quickly identify and fix errors in the code to save time during the test.

Top Resources for Preparation

  • TCS official portal for sample papers and guidelines.
  • Reputed available online coding practice platforms.
  • TCS-specific preparation books and mock tests.

Conclusion

The coding section of TCS NQT is a critical component for candidates aspiring to join TCS. Success in this section requires focused preparation, familiarity with programming concepts, and regular practice of coding problems. 

Utilise the resources and tips shared above to enhance your performance and secure a strong score. For more details, visit the TCS Official Portal

Frequently Asked Questions (FAQs)

1. What is the difficulty level of the coding section in TCS NQT?

It ranges from moderate to advanced, focusing on real-world problem-solving skills.

2. How many coding questions are asked in TCS NQT?

Typically, 1–2 questions are given, depending on the format.

3. Can I choose the programming language for the test?

Yes, candidates can select from C, C++, Java, Python, or Perl.

4. Are the previous year's coding questions repeated?

While exact questions may not repeat, the patterns and types of questions are consistent.

5. Where can I access the previous year's coding questions for TCS NQT?

Sample papers are available on the official TCS website and trusted preparation portals.

Disclaimer: While we strive for accuracy, we do not guarantee its completeness or reliability. Readers are encouraged to verify all facts and statistics from the official company website or check independently before making decisions.

Suggested reads:

Kaihrii Thomas
Associate Content Writer

Instinctively, I fall for nature, music, humour, reading, writing, listening, travelling, observing, learning, unlearning, friendship, exercise, etc., all these from the cradle to the grave- that's ME! It's my irrefutable belief in the uniqueness of all. I'll vehemently defend your right to be your best while I expect the same from you!

TAGS
Placement
Updated On: 27 Nov'24, 05:46 PM IST