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 Ninja Coding Questions: Top 5 Coding Questions with Solution

TCS Ninja is a highly sought-after entry-level role at Tata Consultancy Services (TCS). As part of the selection process, candidates go through a series of assessments, including a coding round that tests their programming skills. This detailed guide covers the TCS Ninja coding questions, previous year patterns, and tips for preparation.
TCS Ninja Coding Round Overview
The TCS Ninja coding round is designed to assess a candidate’s ability to solve algorithmic and data structure-related problems. The difficulty level ranges from easy to moderate, targeting fundamental concepts that every programmer should know.
Here's an overview of what the coding section typically looks like:
Category | Details |
---|---|
Number of Questions | 1-2 coding problems |
Duration | 30 to 45 minutes |
Difficulty Level | Easy to Moderate |
Programming Languages | C, C++, Java, Python |
Key Topics Covered | Data Structures, Algorithms, String Manipulation |
Platform Used | TCS CodeVita or iON platform |
Topics for TCS Ninja Coding Questions
The questions in the TCS Ninja coding section focus on core computer science topics. Below is a breakdown of the most common topics and typical questions asked:
Topic | Description | Example Questions |
---|---|---|
Arrays | Problems involving array manipulations and operations. | Find the maximum sum of a subarray, Rotate an array. |
Strings | String manipulation, pattern matching, and transformations. | Check if a string is a palindrome, Find anagram pairs. |
Sorting & Searching | Implementing basic sorting and searching algorithms. | Binary search, Merge sort, Bubble sort. |
Recursion | Problems that require recursive solutions. | Factorial of a number, Fibonacci sequence using recursion. |
Dynamic Programming | Optimization problems using dynamic programming. | 0/1 Knapsack, Longest common subsequence. |
Greedy Algorithms | Problems solved using the greedy method. | Activity selection, Minimum coins for change. |
Questions Format for Ninja Coding
TCS Ninja coding questions typically come in different formats. Here's what you can expect:
Question Type | Description | Example |
---|---|---|
Simple Algorithmic Problem | Basic algorithmic problems that test your knowledge of loops, conditionals, and basic logic. | Write a program to find the greatest of three numbers. |
Data Structure Manipulation | Problems related to arrays, linked lists, or stacks. | Reverse a linked list, Sort an array using merge sort. |
Pattern-based Questions | String or array pattern problems. | Check for an anagram, Find all unique substrings of a string. |
Dynamic Programming Problems | Optimization problems requiring memoization or tabulation. | Solve the 0/1 knapsack problem using dynamic programming. |
Top 5 Sample Questions with Solution
Problem Statement 1
Ram and Shyam are two friends belonging to two different cities. They exchange messages weekly. The messages are very crucial so that no third person can see the message. But they sent a message via Jadav, a clever person. He usually reads the given messages. So, Ram and Shyam started talking in codewords. They set a convention for every letter in the English Alphabet.
Like ‘a’ to ‘i’ code is 1 to 9 and ‘j’ to ‘z’ code is 10# to 26#.
Now suppose, Ram is sending a message to Shyam denoted by String S.
Can you tell me the decoded message that Shyam receives?
Input Format
The first line of input contains the string S.
Output Format
Return the string which denotes the decoded message that Shyam receives
Constraints
1<=s.length<=10^9
Testcase Input
26#21#13#13#114#97820#
Testcase Output
zummanight
Solution 1: 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 sc=new Scanner(System.in);
String s=sc.next();
StringBuilder sb=new StringBuilder(s);
int i=0;
ArrayList<Integer> al=new ArrayList<>();
for(int k=sb.length()-1;k>=0;k--){
if(sb.charAt(k)=='#'){
String str=sb.substring(k-2,k);
al.add(Integer.parseInt(str));
k=k-2;
}
else
al.add(sb.charAt(k)-'0');
}
Collections.reverse(al);
for(int x:al)
System.out.print((char)(x+96));
}
}
Solution 2: C++
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
string decodeMsg(string s) {
string ans = "";
int i = s.length() - 1;
string temp = "";
while(i >= 0) {
if(s[i] == '#') {
temp = s[i-1];
temp = s[i-2] + temp;
int k = stoi(temp);
ans = char(k - 1 + 'a') + ans;
temp = "";
i -= 3;
} else {
temp = s[i];
int k = stoi(temp);
i--;
temp = "";
ans = char(k - 1 + 'a') + ans;
}
}
return ans;
}
int main() {
string s;
cin>>s;
string ans = decodeMsg(s);
cout<<ans<<endl;
return 0;
}
Solution 3: Python
s=input()
d,a={},""
for i in range(122,96,-1):
# print(chr(i))
if (i-96)>=10:
d[str(str(i-96)+"#")]= chr(i)
else:
d[str(i-96)]= chr(i)
# print(d)
i=0
while(i<len(s)):
# print(i)
if str(s[i:i+3]) in d:
# print(str(s[i:i+3]),end=" ")
a+=str(d.get((s[i:i+3])))
i+=3
# s=s[i+3:]
elif str(s[i:i+2]) in d:
# print(str(s[i:i+2]),end=" ")
a+=d.get(str(s[i:i+2]))
i+=2
elif str(s[i]) in d.keys():
# print(str(s[i]),end=" ")
a+=d.get(str(s[i]))
i+=1
print(a)
Problem Statement 2
You're in a world where magical creatures engage in a peculiar contest, and you've been entrusted with keeping track of the matches. The rules are as follows:
If there is an even number of creatures, they form pairs, and a total of n/2 matches are played. The victors of these matches advance to the next round.
When there's an odd number of creatures, an intriguing twist unfolds. One of them is granted a special power and advances directly to the next stage, while the remaining creatures pair off for matches. The number of matches in this scenario is (n - 1)/2. The creature with the special power joins the winners of these matches in the next round.
Your mission is to determine the overall number of matches that take place in this magical contest until a single champion emerges. How many matches will be required to decide the ultimate winner?
Input Format
An integer n represents the initial number of magical creatures in the contest.
Output Format
An integer represents the total number of matches played in the magical contest until a single champion is determined.
Constraints
1 <= n <= 200
Testcase Input
5
Testcase Output
4
Solution 1: C++
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
int n,ans=0;
cin>>n;
while(n>1)
{
if(n%2==0)
{
ans+=n/2;
n/=2;
}
else
{
ans+=(n-1)/2;
n=n/2+1;
}
}
cout<<ans<<endl;
return 0;
}
Solution 2: 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) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int sum = 0;
while (n > 1) {
if (n % 2 == 0) {
sum += n / 2;
n = n / 2;
} else {
sum += (n - 1) / 2;
n = (n - 1) / 2 + 1;
}
}
System.out.println(sum);
}
}
Solution 3: Python
# Enter your code here. Read input from STDIN. Print output to STDOUT
a=int(input())
c=a-1
print(c)
Problem Statement 3
You are a shopkeeper and bought N pairs of socks of several colours in bulk. The colour of each pair of socks is represented as a non-negative integer. The socks are sold as sets of 3 each. A set of socks consists of 3 socks of the same colour.
You want to find the number of different sets that can be made from the N pairs of socks you bought today.
Note: The order of indices of sock pairs in the set does not matter.
Input Format
The first line of the input contains a single integer N which denotes the number of pairs of socks that you have.
The second line of the input contains n space-separated integers a1, a2, …, an, where ai represents the colour of the ith pair.
Output Format
Print a single integer representing the total number of different sets of 3 socks that can be formed from the N pairs of socks.
Constraints
1 <= N <= 105
0 <= ai <= 10^3
Testcase Input
7
1 3 3 1 1 3 3
Testcase Output
5
Solution 1: Python
from collections import Counter
from math import comb
def count_sock_sets(n, sock_colors):
color_count = Counter(sock_colors)
total_sets = 0
for count in color_count.values():
if count >= 3:
total_sets += comb(count, 3)
return total_sets
n = int(input())
sock_colors = list(map(int, input().split()))
print(count_sock_sets(n, sock_colors))
Solution 2: C++
#include <bits/stdc++.h>
using namespace std;
// Function to compute nC3
int combinations(int n) {
if (n < 3) {
return 0; // nC3 is 0 if n < 3
}
return (n * (n - 1) * (n - 2)) / 6;
}
int main() {
int n;
cin >> n;
unordered_map<int, int> m;
int maxe = 0;
for (int i = 0; i < n; i++) {
int ele;
cin >> ele;
m[ele]++;
maxe = max(maxe, m[ele]);
}
int cnt = 0;
for (auto itr : m) {
cnt += combinations(itr.second); // Calculate nC3 for each frequency
}
cout << cnt << endl;
return 0;
}
Solution 3: 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 sc = new Scanner(System.in);
int N = sc.nextInt();
int[] socks = new int[N];
for (int i = 0; i < N; i++) {
socks[i] = sc.nextInt();
}
sc.close();
int[] colorCount = new int[1001];
for (int color : socks) {
colorCount[color]++;
}
int totalSets = 0;
for (int count : colorCount) {
if (count >= 3) {
totalSets += (count * (count - 1) * (count - 2)) / 6;
}
}
System.out.println(totalSets);
}
}
Problem Statement 4
Ram gave Shyaam a challenge, he gave shyaam the head of a linked list, and an integer k.
He asked Shyaam to swap the values of the Kth node from the beginning and the Kth node from the end (the list is 1-indexed).
Note: The number of nodes in the list is N.
Input Format
The first line contains an integer N, representing the number of nodes in the linked list.
The second line contains N space-separated integers, each representing the value of a node in the linked list.
The third line contains an integer K, indicating the positions of the nodes to be swapped.
Output Format
Output the linked list after swapping the values of the two specified nodes.
Constraints
1 <= K <= N <= 10^5
0 <= Node.val <= 10^2
Testcase Input
5
1 2 3 4 5
2
Testcase Output
1 4 3 2 5
Solution 1: Java
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Main {
public static void main(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
LinkedList<Integer> l = new LinkedList<>();
Scanner in = new Scanner(System.in);
int n= in.nextInt();
for(int i=0;i<n;i++){
l.add(in.nextInt());
}
int k=in.nextInt();
int temp=l.get(k-1);
l.set(k-1,l.get(n-k));
l.set(n-k,temp);
for(int e: l){
System.out.print(e+" ");
}
}
}
Solution 2: C++
#include <list>
#include <iostream>
#include <iterator>
using namespace std;
int main() {
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
int n;
cin>>n;
list<int> L1;
for(int i=0;i<n;i++){
int dummy;
cin>>dummy;
L1.push_back(dummy);
}
int index;
cin>>index;
list<int>::iterator itr;
list<int>::reverse_iterator ptr;
int counter=0;
for(itr=L1.begin(),ptr=L1.rbegin();itr!=L1.end() && ptr!=L1.rend();itr++,ptr++){
if(counter==index-1){
int temp=*itr;
*itr=*ptr;
*ptr=temp;
}
counter++;
}
for(auto it=L1.begin();it!=L1.end();it++){
cout<<*it<<" ";
}
return 0;
}
Solution 3: Python
# Enter your code here. Read input from STDIN. Print output to STDOUT
n=int(input())
li=list(map(int,input().split()))
k=int(input())
li[k-1],li[-k]=li[-k],li[k-1]
for ele in li:
print(ele,end=" ")
Problem Statement 5
There are n spaceships at given lightyears away from the Earth and travelling to reach a distant star system at k lightyears away from Earth. You are given two integer arrays, position and speed, both of length n, where
P[i] is the current distance of the ith spaceship
S[i] is the speed of the ith spaceship in lightyears per year.
As the spaceships travel toward the star system, an interesting phenomenon occurs: when a faster spaceship catches up to a slower one, it reduces its speed to match the slower spaceship's speed, forming a fleet. A fleet is a group of one or more spaceships that travel together at the same speed.
Given this information, determine the number of distinct spacecraft fleets that will arrive at the destination star system. A fleet is considered distinct if no other fleet arrives at the destination at the same time while travelling together.
Input Format
The first line contains an integer 'n', representing the total number of spaceships.
The second line contains an integer 'k', representing the distance of the star system from Earth.
The third line contains 'n' space-separated integers denoting the current distance of the i-th spaceship from Earth.
The fourth line contains 'n' space-separated integers denoting the speed of the i-th spaceship.
Output Format
Return the number of spacecraft fleets that will arrive at the destination.
Constraints
1 <= n <= 10^5
0 < k <= 10^6
0 <= P[i] < target
0 < S[i] <= 10
Testcase Input
4
14
10 8 5 3
2 4 1 3
Testcase Output
2
Solution 1: Python
# Enter your code here. Read input from STDIN. Print output to STDOUT
def count_fleets(n, k, position, speed):
# Step 1: Calculate the time for each spaceship to reach the target
time = [(k - position[i]) / speed[i] for i in range(n)]
# Step 2: Sort spaceships by their position from farthest to closest
ships = sorted(zip(position, time), reverse=True)
# Step 3: Count the number of distinct fleets
fleets = 0
current_time = 0
for _, t in ships:
if t > current_time:
fleets += 1
current_time = t
return fleets
# Input
n = int(input()) # Number of spaceships
k = int(input()) # Target distance
position = list(map(int, input().split())) # Current positions of the spaceships
speed = list(map(int, input().split())) # Speeds of the spaceships
# Output the number of fleets
print(count_fleets(n, k, position, speed))
Solution 2: C++
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int countFleets(int n, int k, vector<int>& position, vector<int>& speed) {
vector<pair<int, double>> ships(n); // To store positions and corresponding times to reach the target
// Calculate the time for each spaceship to reach the target
for (int i = 0; i < n; i++) {
double time = (double)(k - position[i]) / speed[i];
ships[i] = {position[i], time};
}
// Sort ships based on their starting positions (farthest first)
sort(ships.begin(), ships.end(), greater<pair<int, double>>());
int fleets = 0;
double lastFleetTime = 0.0;
// Iterate over sorted ships to count fleets
for (int i = 0; i < n; i++) {
if (ships[i].second > lastFleetTime) {
fleets++;
lastFleetTime = ships[i].second; // Update the latest fleet's time
}
}
return fleets;
}
int main() {
int n, k;
cin >> n >> k;
vector<int> position(n), speed(n);
for (int i = 0; i < n; i++) {
cin >> position[i];
}
for (int i = 0; i < n; i++) {
cin >> speed[i];
}
// Output the number of distinct fleets
cout << countFleets(n, k, position, speed) << endl;
return 0;
}
Solution 3: Java
import java.util.*;
public class Main {
public static int countFleets(int n, int target, int[] position, int[] speed) {
List<Pair> sorted = new ArrayList<>(); // Store position and time to reach target
// Calculate time taken by each spacecraft to reach target
for (int i = 0; i < n; ++i) {
sorted.add(new Pair(position[i], (double)(target - position[i]) / speed[i]));
}
// Sort spacecraft by position in descending order
Collections.sort(sorted, (a, b) -> b.position - a.position);
int fleets = 0;
double maxTime = 0;
// Iterate over sorted spacecraft
for (Pair p : sorted) {
if (p.time > maxTime) {
maxTime = p.time;
fleets++; // Increment fleet count if spacecraft takes more time to reach target
}
}
return fleets;
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int target = sc.nextInt();
int[] position = new int[n];
int[] speed = new int[n];
for (int i = 0; i < n; ++i) {
position[i] = sc.nextInt();
}
for (int i = 0; i < n; ++i) {
speed[i] = sc.nextInt();
}
int result = countFleets(n, target, position, speed);
System.out.println(result);
}
static class Pair {
int position;
double time;
Pair(int position, double time) {
this.position = position;
this.time = time;
}
}
}
Enhance your coding skills by practicing coding questions across various levels. Click here to start your coding journey and master programming!
Preparation Tips
Here are some tips to ace the TCS Ninja coding round:
Strategy | Description |
---|---|
Practice Core Concepts | Focus on mastering basic data structures and algorithms. Ensure you understand how to implement sorting algorithms, recursion, and string manipulations. |
Time Management | The coding round is timed, so practice solving problems quickly and accurately. Split time effectively between easy and moderate-level questions. |
Optimize Code | Practice writing code that is not only correct but also efficient. Focus on reducing time complexity wherever possible. |
Conclusion
The TCS Ninja coding round is a critical part of the recruitment process, testing your problem-solving ability and programming knowledge. Whether you’re a fresher or have some experience, consistent practice in algorithms, data structures, and coding problems will help you excel. Focus on solving previous year's questions, improve your speed, and keep practising to enhance your coding skills.
Disclaimer: While we have gathered as much information from Deloitte's official website as possible, we have also included sources gathered from available online sources. Therefore, readers are advised to check and stay updated with the official website.
Frequently Asked Questions (FAQs)
1. What is the difficulty level of the coding questions in TCS Ninja?
The coding questions in the TCS Ninja exam are generally of easy to moderate difficulty, focusing on fundamental concepts like arrays, strings, and basic algorithms.
2. How many coding questions are asked in the TCS Ninja exam?
Typically, the exam includes 1-2 coding questions that need to be solved within 30 to 45 minutes.
3. Which programming languages can be used in the TCS Ninja coding round?
You can use programming languages such as C, C++, Java, Python, or Perl, depending on the platform.
4. What topics should I focus on for TCS Ninja coding questions?
Key topics include arrays, strings, recursion, sorting and searching algorithms, and basic dynamic programming problems.
Suggested reads:
-
Deloitte Coding Questions: Top 5 Coding Questions for Freshers
-
TCS Digital Recruitment Process: Latest Updates & Tips for Freshers
-
HCL Logical Reasoning Questions and Answers: Top 5 Sample MCQs
-
HCL Aptitude Test: Top 5 Questions and Answers for Freshers (MCQs)
-
TCS Digital Aptitude Questions and Answers: Top 5 Sample MCQs
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 3 days ago