TCS NQT
Table of content:
- TCS NQT Recruitment Process: Overview
- TCS NQT Hiring 2025: Eligibility Criteria
- TCS NQT Hiring 2025: Application Process & Link
- Important Dates: TCS NQT Hiring 2025
- TCS NQT Exam Structure: Detailed Breakdown
- TCS NQT Hiring Categories
- TCS NQT 2025: Preparation Resources
- Conclusion
- Frequently Asked Questions (FAQs)
Table of content:
- Understanding TCS NQT Previous Year's Papers
- TCS NQT Latest Exam Pattern
- Download PDFs of TCS NQT Previous Year Sample Papers
- Related TCS NQT Resources
- Top 5 MCQs with Answers for TCS NQT 2025
- Conclusion
- Frequently Asked Questions (FAQs)
Table of content:
- Overview of TCS Ninja Previous Year Papers
- Marking Scheme and Level of Exam
- Top 5 sample MCQs for TCS ninja Exam
- Benefits of Practicing Previous Year Papers
- Preparation Tips for TCS Ninja Exam
- Conclusion
- Frequently Asked Questions (FAQs)
Table of content:
- Key Features of TCS NQT Aptitude Section
- Sample Question Patterns
- Top 5 MCQs for TCS NQT Aptitude Test
- Effective Preparation Tips
- Conclusion
- Frequently Asked Questions (FAQs)
Table of content:
- Key Topics in TCS NQT Verbal Ability Section
- Top 5 MCQs with Answers for TCS NQT Verbal Ability
- In-depth Tips & Strategies for Each Verbal Ability Section
- Conclusion
- Frequently Asked Questions (FAQs)
Table of content:
- Understanding TCS NQT Reasoning Ability Section
- Exam Structure: TCS NQT Reasoning Section
- Sample Reasoning Question Patterns
- Top 5 MCQs with Answers for TCS NQT Reasoning
- Effective Preparation Strategies
- Conclusion
- Frequently Asked Questions (FAQs)
Table of content:
- Key Topics for TCS NQT Coding Section
- TCS NQT Coding Test Pattern
- Top 5 TCS NQT Coding Questions with Answers
- Tips to Ace TCS NQT Coding Section
- Conclusion
- Frequently Asked Questions (FAQs)
Table of content:
- TCS NQT: Personal Interview
- TCS NQT Interview: Technical Round Questions
- TCS NQT Interview: Management Round Questions
- TCS NQT Interview: HR Interview Round Questions
Table of content:
- TCS Managerial Round Interview Questions
- TCS Managerial Round Interview Questions: Tips
Table of content:
- TCS Ninja Detailed Recruitment Process
- Exam Pattern of TCS NQT
- TCS Ninja Technical Interview
- TCS Ninja HR Interview
- TCS Ninja Offer Rollout
- Tips for TCS Ninja Recruitment
- Conclusion
- Frequently Asked Questions (FAQs)
Table of content:
- Overview of TCS Ninja Aptitude Test
- TCS Ninja Aptitude Exam Pattern
- Selected Ninja Aptitude Questions & Solutions (MCQs)
- Conclusion
- Frequently Asked Questions
Table of content:
- Topics for TCS Ninja Coding Questions
- Questions Format for Ninja Coding
- Top 5 Sample Questions with Solution
- Preparation Tips
- Conclusion
- Frequently Asked Questions (FAQs)
Table of content:
- Overview of TCS Ninja Interview Questions
- Best TCS Ninja Interview Questions & Answers
- Conclusion
- Frequently Asked Questions (FAQs)
Table of content:
- Overview of TCS Digital Recruitment Process
- Updated Exam Pattern & Structure
- Advanced Quantitative Section Details
- Reasoning Section
- Preparation Tips & Strategies
- Conclusion
- Frequently Asked Questions (FAQs)
Table of content:
- About TCS
- TCS Digital Eligibility Criteria
- TCS Digital Syllabus
- TCS Digital Exam Pattern
- TCS Digital Salary
- TCS Digital Interview Process
- Digital Exam for TCS Employees
- TCS Digital Preparation Tips
- Conclusion
- Frequently Asked Questions (FAQs)
Table of content:
- TCS Digital Aptitude Exam Format
- TCS Digital Aptitude Syllabus
- Advanced Aptitude Questions for TCS Digital
- Top 5 TCS Digital Aptitude Sample MCQs
- Preparation Tips
- Conclusion
- Frequently Asked Questions (FAQs)
Table of content:
- Digital Coding Questions: Topics Covered
- TCS Digital Previous Year Coding Questions
- Top 5 Digital Coding Questions with Solution
- Digital Advanced Coding Questions
- TCS Digital Coding Round Questions
- Digital Coding Questions for Freshers
- How to Prepare for TCS Digital Coding Exam?
- Conclusion
- Frequently Asked Questions (FAQs)
Table of content:
- TCS Digital Interview Process for Freshers
- TCS Digital Interview Questions and Answers
- Top 5 Sample MCQs for TCS Digital Interview
- Tips for Freshers Preparing for TCS Digital
- Conclusion
- Frequently Asked Questions (FAQs)
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
- Programming Basics
- Data types, loops, and conditions.
- Functions and recursion.
- Data Structures
- Arrays, linked lists, stacks, and queues.
- Binary trees and graphs.
- Algorithms
- Sorting and searching algorithms.
- Dynamic programming.
- 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++
#include <bits/stdc++.h>
using namespace std;
// Function to process the string according to the typewriter rules
string processString(const std::string &s) {
stack<char> st;
for (char c : s) {
if (c == '#') {
if (!st.empty()) {
st.pop();
}
} else {
st.push(c);
}
}
// Build the resulting string from the stack
string result;
while (!st.empty()) {
result += st.top();
st.pop();
}
// Reverse the result because stack gives us characters in reverse order
reverse(result.begin(), result.end());
return result;
}
int main() {
string bob, alice;
cin >> bob;
cin >> alice;
string processedBob = processString(bob);
string processedAlice = processString(alice);
if (processedBob == processedAlice) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
return 0;
}
Solution Java
import java.util.Stack;
import java.util.*;
public class BackspaceCompare {
public static boolean backspaceCompare(String bob, String alice) {
String bobProcessed = processString(bob);
String aliceProcessed = processString(alice);
return bobProcessed.equals(aliceProcessed);
}
private static String processString(String s) {
Stack<Character> stack = new Stack<>();
for (char c : s.toCharArray()) {
if (c == '#') {
if (!stack.isEmpty()) {
stack.pop();
}
} else {
stack.push(c);
}
}
StringBuilder sb = new StringBuilder();
for (char c : stack) {
sb.append(c);
}
return sb.toString();
}
public static void main(String[] args) {
// Test case 0
Scanner sc = new Scanner(System.in);
String str1 = sc.nextLine();
String str2 = sc.nextLine();
System.out.println((backspaceCompare(str1,str2) ? "YES" : "NO"));
}
}
Solution Python
# Enter your code here. Read input from STDIN. Print output to STDOUT
def process_string(s):
result = []
for char in s:
if char == '#':
if result:
result.pop()
else:
result.append(char)
return ''.join(result)
def compare_strings(bob, alice):
return process_string(bob) == process_string(alice)
# Input
bob = input().strip()
alice = input().strip()
# Output
if compare_strings(bob, alice):
print("YES")
else:
print("NO")
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++
#include <iostream>
#include <vector>
using namespace std;
class DoubleNode {
public:
int doubledata;
DoubleNode* doubleprev;
DoubleNode* doublenext;
DoubleNode(int data) {
this->doubledata = data;
this->doubleprev = nullptr;
this->doublenext = nullptr;
}
};
class Node {
public:
int data;
Node* next;
Node(int data) {
this->data = data;
this->next = nullptr;
}
};
void createNodeList(vector<vector<int>>& arr, vector<Node*>& nodeList) {
for (int i = 0; i < arr.size(); i++) {
Node* head = nullptr;
Node* prev = nullptr;
for (int j = 0; j < arr[0].size(); j++) {
Node* newNode = new Node(arr[i][j]);
if (!head) {
head = newNode;
} else {
prev->next = newNode;
}
prev = newNode;
}
nodeList.push_back(head);
}
}
DoubleNode* createDoubleLinkedList(vector<Node*>& nodeList) {
DoubleNode* head = nullptr;
DoubleNode* tail = nullptr;
vector<int> tempList;
// Add even-index nodes first
for (int i = 0; i < nodeList.size(); i += 2) {
Node* current = nodeList[i];
while (current) {
tempList.push_back(current->data);
current = current->next;
}
}
// Add odd-index nodes next
for (int i = 1; i < nodeList.size(); i += 2) {
Node* current = nodeList[i];
while (current) {
tempList.push_back(current->data);
current = current->next;
}
}
for (int i = 0; i < tempList.size(); i++) {
DoubleNode* newNode = new DoubleNode(tempList[i]);
if (!head) {
head = newNode;
tail = newNode;
} else {
tail->doublenext = newNode;
newNode->doubleprev = tail;
tail = newNode;
}
}
return head;
}
void printDoubleLinkedList(DoubleNode* head) {
DoubleNode* current = head;
while (current) {
cout << current->doubledata << " <---> ";
current = current->doublenext;
}
cout << "null" << endl;
}
int main() {
int n, m;
cin >> n >> m;
vector<vector<int>> arr(n, vector<int>(m));
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
cin >> arr[i][j];
}
}
vector<Node*> nodeList;
createNodeList(arr, nodeList);
DoubleNode* doubleLinkedList = createDoubleLinkedList(nodeList);
printDoubleLinkedList(doubleLinkedList);
return 0;
}
Solution Java
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int N = in.nextInt();
int M = in.nextInt();
int input[][] = new int[N][M];
for(int i=0;i<N;i++)
for(int j=0;j<M;j++)
input[i][j] = in.nextInt();
for(int i=0;i<N;i++){
for(int j = 0;j<M;j++)
if(i%2==0)
System.out.print(input[i][j]+" <---> ");
}
for(int i=0;i<N;i++){
for(int j = 0;j<M;j++)
if(i%2!=0)
System.out.print(input[i][j]+" <---> ");
}
System.out.println("null");
}
}
Solution Python
class Node:
def __init__(self, data):
self.data = data
self.prev = None
self.next = None
def construct_linked_list(N, M, array):
# Step 1: Create an ArrayList of linked list heads for each row
node_rows = []
for i in range(N):
head = None
tail = None
for j in range(M):
new_node = Node(array[i][j])
if head is None: # Initialize the head of the row
head = new_node
tail = new_node
else: # Add new node to the row's linked list
tail.next = new_node
new_node.prev = tail
tail = new_node
node_rows.append(head)
# Step 2: Separate even-indexed and odd-indexed rows
even_rows = [node_rows[i] for i in range(N) if i % 2 == 0]
odd_rows = [node_rows[i] for i in range(N) if i % 2 != 0]
# Step 3: Merge the even and odd rows into a single doubly linked list
final_head = None
final_tail = None
def append_row_to_list(row_head):
nonlocal final_head, final_tail
current = row_head
while current:
new_node = Node(current.data)
if final_head is None: # Initialize the final list
final_head = new_node
final_tail = new_node
else: # Add to the final list
final_tail.next = new_node
new_node.prev = final_tail
final_tail = new_node
current = current.next
# Append all even rows first, then odd rows
for row in even_rows:
append_row_to_list(row)
for row in odd_rows:
append_row_to_list(row)
# Step 4: Print the final doubly linked list
result = []
current = final_head
while current:
result.append(str(current.data))
current = current.next
result.append("null")
return " <---> ".join(result)
# Input
N = int(input()) # Number of rows
M = int(input()) # Number of columns
array = []
for _ in range(N):
array.append(list(map(int, input().split())))
# Output
print(construct_linked_list(N, M, array))
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++
#include <bits/stdc++.h>
using namespace std;
int main(){
int i,j=0,k=0,cnt=0,mx=INT_MIN;
string s;
getline(cin,s);
for(i=0;i<s.length();i++){
k=s[i];
if(s[i]=='.'||s[i]==','){
mx=max(mx,cnt);
j=0;
cnt=0;
}else{
if((k>=65&&k<=90)||(k>=97&&k<=122)){
if(j==0){
cnt+=1;
}
j+=1;
}else{
j=0;
}
}
}
mx=max(mx,cnt);
cout<<mx;
return 0;
}
Solution Java
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
public static void main(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
Scanner sc = new Scanner(System.in);
String s1 = sc.nextLine();
int n =s1.length();
char s[]= s1.toCharArray();
int count=0,max_count=0;
for(int i=0; i<n; i++){
if(s[i]=='.' || s[i]==','){
max_count = Math.max(max_count, count+1);
count=0;
}
if(s[i]==' '){
if(s[i-1]=='.' || s[i]==',') continue;
count++;
}
}
System.out.println(max_count);
}
}
Solution Python
# Enter your code here. Read input from STDIN. Print output to STDOUT
def longest_sentence_length(paragraph):
# Split the paragraph into sentences based on '.' and ','
sentences = paragraph.replace('.', ',').split(',')
# Initialize the max length to 0
max_length = 0
# Iterate through each sentence
for sentence in sentences:
# Strip any leading/trailing whitespace and split into words
words = sentence.strip().split()
# Update max_length if this sentence is longer
max_length = max(max_length, len(words))
return max_length
# Input
paragraph = input().strip()
# Output
print(longest_sentence_length(paragraph))
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
# Enter your code here. Read input from STDIN. Print output to STDOUT
n,x=map(int,input().split())
l=list(map(int,input().split()))
d={}
for i in l:
if i in d:
d[i]+=1
else:
d[i]=1
l.sort()
c=0
# print(d)
if x>1:
for i in l:
if d[i]>0:
tc=d[i]
req=i*x
ttc=0
if req in d:
ttc+=d[req]
if ttc==0:
c+=tc
d[i]=0
else:
if tc==ttc:
d[i]=0
d[req]=0
elif tc>ttc:
c+=tc-ttc
d[i]=0
d[req]=0
else:
d[i]=0
d[req]-=tc
# print(i,req,tc,ttc,c,d)
print(c)
elif x==1:
for i in d:
if d[i]%2==0:
pass
else:
c+=1
print(c)
Solution C++
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<map>
using namespace std;
int main() {
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
long long n,x;
cin>>n>>x;
map<long long ,long long > mp;
vector<long long>v(n);
for(int i=0;i<n;i++)
{ cin>>v[i];
mp[v[i]]++;
}
long long ans=0;
if(x==1)
{
for(auto it: mp)
{
if(it.second%2)
ans++;
}
cout<<ans;
return 0;
}
for (auto it = mp.begin(); it != mp.end(); ++it) {
long long num = it->first;
long long freq = it->second;
if (x != 1) { // Only pair distinct elements if x != 1
long long t = num * x;
if (mp.find(t) != mp.end()) {
long long pairCount = min(freq, mp[t]);
ans += pairCount * 2;
mp[num] -= pairCount;
mp[t] -= pairCount;
}
}
}
cout<< abs(n-ans);
return 0;
}
Solution Java
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
// Read inputs
int n = scanner.nextInt();
long x = scanner.nextLong();
int[] ar = new int[n];
for (int i = 0; i < n; i++) {
ar[i] = scanner.nextInt();
}
// Sort the array
Arrays.sort(ar);
boolean[] vis = new boolean[n];
int j = 0, q = 0;
int ans = 0;
for (int i = 0; i < n; i++) {
if (vis[i]) {
continue;
}
if (ar[i] * x > ar[j]) {
while (j < n && ar[i] * x >= ar[j]) {
q = ++j;
}
q = --j;
}
if (i < q && ar[i] * x == ar[q]) {
vis[q--] = true;
} else {
ans++;
}
}
System.out.println(ans);
}
}
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++
#include <bits/stdc++.h>
using namespace std;
int main() {
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
string s;
cin>>s;
int arr[26];
memset(arr,0,sizeof(arr));
for(int i=0;i<s.size();i++){
arr[s[i]-'a']++;
}
int f=0;
for(int i=0;i<26;i++){
if(arr[i]==0)
{
f=1;
break;
}
}
if(f)
cout<<"False"<<endl;
else
cout<<"True"<<endl;
return 0;
}
Solution Java
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
class Solution {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
String str=sc.next();
TreeSet<Character> set=new TreeSet<>();
for(int i=0;i<str.length();i++)
set.add(str.charAt(i));
if(set.size()==26)
System.out.print("True");
else
System.out.print("False");
}
}
Solution Python
# Enter your code here. Read input from STDIN. Print output to STDOUT
def has_all_letters(s):
# Define the set of all lowercase English letters
alphabet_set = set('abcdefghijklmnopqrstuvwxyz')
# Convert the input string to a set
input_set = set(s)
# Check if all letters are present in the input set
if alphabet_set.issubset(input_set):
return "True"
else:
return "False"
# Input reading
input_string = input().strip() # Read input and remove any extra spaces
# Output the result
print(has_all_letters(input_string))
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
- Practice Previous Year Questions
Familiarise yourself with typical problems using TCS NQT previous papers. - Master Fundamentals
Strengthen your understanding of syntax and basic constructs in your preferred language. - Improve Speed and Accuracy
Use online coding platforms like HackerRank or LeetCode to practice under timed conditions. - 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:
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!
Comments
Add commentLogin to continue reading
And access exclusive content, personalized recommendations, and career-boosting opportunities.

Subscribe
to our newsletter
Blogs you need to hog!

55+ Data Structure Interview Questions For 2025 (Detailed Answers)

How To Negotiate Salary With HR: Tips And Insider Advice

Best 80+ TCS NQT Most Commonly Asked Interview Questions for 2025

Divyansh Shrivastava 1 week ago
Ujjawal Shrivastava 1 week ago