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 Digital Coding Questions: Top 5 Coding Questions & Solutions

TCS Digital is a premium role offered by Tata Consultancy Services (TCS) that focuses on digital technologies. To secure this role, candidates must go through a rigorous selection process, including a challenging coding round. This guide provides a comprehensive overview of TCS Digital coding questions, covering various aspects such as previous year questions, advanced coding problems, and the types of questions to expect.
TCS Digital Coding Round Overview
The coding round is a crucial stage in the TCS Digital hiring process. It typically consists of 2-3 questions that test the candidate's problem-solving abilities, coding skills, and algorithmic knowledge. The time duration for this round is usually between 60 to 90 minutes.
Category | Details |
---|---|
Number of Questions | 2-3 coding problems |
Duration | 60 to 90 minutes |
Difficulty Level | Moderate to Advanced |
Languages Allowed | C, C++, Java, Python, etc. |
Focus Areas | Data Structures, Algorithms, Dynamic Programming |
Digital Coding Questions: Topics Covered
The questions in TCS Digital coding assessments cover a wide range of programming topics. Here's a breakdown of the topics and the types of questions you may encounter:
Topic | Description | Example Questions |
---|---|---|
Data Structures | Implementing and manipulating data structures such as arrays, linked lists, stacks, and trees. | Reverse a linked list, Find a cycle in a graph |
Algorithms | Questions involving searching, sorting, and optimization techniques. | Quick Sort, Binary Search, Dijkstra's Algorithm |
Dynamic Programming (DP) | Problems requiring memoization or tabulation to optimize solutions. | Knapsack problem, Longest Common Subsequence |
Greedy Algorithms | Optimization problems are solved through the greedy approach. | Activity selection, Fractional Knapsack |
String Manipulation | String-related problems such as pattern matching and transformations. | Palindrome check, Anagram detection |
Recursion & Backtracking | Recursive problems that involve decision trees and combinatorial searches. | N-Queens, Subset Sum problem |
TCS Digital Previous Year Coding Questions
TCS Digital often repeats coding patterns from previous years with slight modifications. Here are some examples of the previous year's coding questions:
Question | Type | Topic | Difficulty |
---|---|---|---|
Write a program to find the shortest path in a weighted graph using Dijkstra's algorithm. | Algorithm | Graph Theory | Advanced |
Given a matrix, rotate it 90 degrees clockwise. | Data Structures | Matrix Manipulation | Moderate |
Implement a function to check if two strings are anagrams of each other. | String Manipulation | Sorting, String | Easy |
Solve the 0/1 Knapsack problem using dynamic programming. | Dynamic Programming | DP, Recursion | Advanced |
Find all permutations of a given string using recursion. | Backtracking | String, Recursion | Moderate |
Enhance your coding skills by practicing coding questions across various levels. Click here to start your coding journey and master programming!
Top 5 Digital Coding Questions with Solution
Problem Statement 1
One day, Jack finds a string of characters. He is very keen to arrange them in reverse order, i.e., the first characters become the last characters, the second characters become the second-last characters, and so on.
Now he wants your help to find the kth character from the new string formed after reverse the original string.
Note: String contains only lowercase Latin letters.
Input Format
The first line contains two integers n, k — the length of array and the value of k respectively.
The second line contains a string containing n characters.
Output Format
Print a single line containing the kth character of the string.
Constraints
1 ≤ k ≤ n≤ 10^6
Testcase Input
5 2
abdfa
Testcase Output
f
Solution 1: C++
b#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
using ll = long long;
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define sz(a) (int) ((a).size())
#define pb push_back
#define fi first
#define se second
#define f0r(i, a, b) for(int i = (a); i < (b); ++i)
#define f0rr(i, a, b) for(int i = (a - 1); i >= (b); --i)
#define trav(i, v) for(auto &i : (v))
template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
template<typename T> T pow(T a, T b) { T res = 1; f0r(i, 0, b) res = res * a; return res; }
template<typename T> void ckmax(T &a, T b) { a = max(a, b); }
template<typename T> void ckmin(T &a, T b) { a = min(a, b); }
int dx4[] = {0, 1, 0, -1};
int dy4[] = {1, 0, -1, 0};
int dx8[] = {-1, -1, -1, 0, 1, 1, 1, 0};
int dy8[] = {-1, 0, 1, 1, 1, 0, -1, -1};
const int N2 = 1004, N = 200004;
const ll linf = 1000000000000000000;
const int inf = 1000010000;
int n, m, x, y;
vector<int> v(N), dp(N);
vector<vector<int>> mat(N2, vector<int> (N2));
// <===================================================================================================>
int main(){
cin.tie(nullptr)->sync_with_stdio(false);
clock_t time_req;
time_req = clock();
int tt = 1;
// cin >> tt;
f0r(T, 1, tt + 1) {
cin >> n >> m;
string s;
cin >> s;
--m;
while(sz(s) && m) {
s.pop_back();
--m;
}
cout << s.back() ;
}
time_req = clock() - time_req;
// cerr << "Time Taken: "<< (float)time_req/CLOCKS_PER_SEC << " seconds" << "\n";
return 0;
}
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) {
/* 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 k = sc.nextInt();
String names = sc.next();
System.out.println(names.charAt(n-k));
}
}
Solution 3: Python
# Enter your code here. Read input from STDIN. Print output to STDOUT
n, k = map(int, input().split())
s = input()
print(s[::-1][k-1])
Problem Statement 2
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.
Testcase Input
ab#c
ad#c
Testcase Output
YES
Solution 1: 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 2: 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")
Solution 3: Java
import java.util.Stack;
import java.util.*;
public class Main {
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"));
}
}
Problem Statement 3
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
class ListNode:
def __init__(self, val=0, next=None):
self.val = val
self.next = next
# Helper function to create a linked list from a list of values
def create_linked_list(values):
if not values:
return None
head = ListNode(values[0])
current = head
for value in values[1:]:
current.next = ListNode(value)
current = current.next
return head
# Helper function to convert a linked list back to a Python list
def linked_list_to_list(head):
values = []
current = head
while current:
values.append(current.val)
current = current.next
return values
# Function to swap the Kth node from the start and the Kth node from the end
def swap_nodes(head, N, K):
if not head or K > N:
return head
# Find Kth node from the start
first_node = head
for _ in range(K - 1):
first_node = first_node.next
# Find Kth node from the end (N-K+1 th node from the start)
second_node = head
for _ in range(N - K):
second_node = second_node.next
# Swap the values of the two nodes
first_node.val, second_node.val = second_node.val, first_node.val
return head
# Main function to handle input/output
if __name__ == "__main__":
# Read inputs
N = int(input()) # Number of nodes in the linked list
values = list(map(int, input().split())) # The list of node values
K = int(input()) # Position K
# Create linked list from the input values
head = create_linked_list(values)
# Swap the Kth node from the start with the Kth node from the end
head = swap_nodes(head, N, K)
# Convert the linked list back to a list and print the result
result = linked_list_to_list(head)
print(" ".join(map(str, result)))
Problem Statement 4
There are n spaceship at given lightyears away from the earth and traveling to reach a distant star system at k lightyear 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 traveling 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;
}
}
}
Problem Statement 5
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
Testcase Input
4
6
2 4 5 3 6 7
5 3 6 3 6 7
3 6 7 2 6 8
4 2 1 6 8 9
Testcase Output
2 <---> 4 <---> 5 <---> 3 <---> 6 <---> 7 <---> 3 <---> 6 <---> 7 <---> 2 <---> 6 <---> 8 <---> 5 <---> 3 <---> 6 <---> 3 <---> 6 <---> 7 <---> 4 <---> 2 <---> 1 <---> 6 <---> 8 <---> 9 <---> null
Solution 1: Java
import java.util.*;
public class Main {
static class doubleNode {
int doubledata;
doubleNode doubleprev;
doubleNode doublenext;
doubleNode(int doubledata) {
this.doubledata = doubledata;
}
}
static class Node {
int data;
Node next;
Node(int data) {
this.data = data;
next = null;
}
}
static void CreateNodeList(int [][] arr , List<Node> list ){
for(int i = 0 ; i< arr.length; i++){
Node head = null, prev = null;
for(int j = 0; j < arr[0].length; j++){
if (head == null) {
head = new Node(arr[i][j]);
prev = head;
} else {
prev.next = new Node(arr[i][j]);
prev = prev.next;
}
}
list.add(head);
}
}
static doubleNode CreateLinkedList(List<Node> list ){
doubleNode head = null ;
doubleNode tail = null;
for(int i =0 ; i < list.size(); i++){
Node nn = list.get(i);
while( nn != null){
doubleNode n = new doubleNode(nn.data);
if(head == null){
head = n;
tail = head;
head.doubleprev = null;
tail.doublenext = null;
}else{
tail.doublenext = n;
n.doubleprev = tail;
tail = n;
tail.doublenext = null;
}
nn = nn.next;
}
i++;
}
for(int i =1 ; i < list.size(); i++){
Node nn = list.get(i);
while( nn != null){
doubleNode n = new doubleNode(nn.data);
if(head == null){
head = n;
tail = head;
head.doubleprev = null;
tail.doublenext = null;
}else{
tail.doublenext = n;
n.doubleprev = tail;
tail = n;
tail.doublenext = null;
}
nn = nn.next;
}
i++;
}
return head;
}
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int m = scanner.nextInt();
int[][] arr = new int[n][m];
// Input the 2D array
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
arr[i][j] = scanner.nextInt();
}
}
// Create node ArrayList
List<Node> list = new ArrayList<>();
CreateNodeList(arr, list);
// Create linked list
doubleNode current = CreateLinkedList(list);
// Print linked list
while (current != null) {
System.out.print(current.doubledata + " <---> ");
current = current.doublenext;
}
System.out.print("null");
}
}
Solution 2: 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 3: Python
class DoubleNode:
def __init__(self, doubledata):
self.doubledata = doubledata
self.doubleprev = None
self.doublenext = None
class Node:
def __init__(self, data):
self.data = data
self.next = None
def create_node_list(arr):
list_of_nodes = []
for row in arr:
head = None
prev = None
for value in row:
new_node = Node(value)
if head is None:
head = new_node
else:
prev.next = new_node
prev = new_node
list_of_nodes.append(head)
return list_of_nodes
def create_double_linked_list(list_of_nodes):
head = None
tail = None
# First add nodes from even index rows
for i in range(0, len(list_of_nodes), 2):
current = list_of_nodes[i]
while current:
new_double_node = DoubleNode(current.data)
if head is None:
head = new_double_node
tail = head
else:
tail.doublenext = new_double_node
new_double_node.doubleprev = tail
tail = new_double_node
current = current.next
# Then add nodes from odd index rows
for i in range(1, len(list_of_nodes), 2):
current = list_of_nodes[i]
while current:
new_double_node = DoubleNode(current.data)
if head is None:
head = new_double_node
tail = head
else:
tail.doublenext = new_double_node
new_double_node.doubleprev = tail
tail = new_double_node
current = current.next
return head
def print_double_linked_list(head):
current = head
while current:
print(f"{current.doubledata} <---> ", end="")
current = current.doublenext
print("null")
if __name__ == "__main__":
n = int(input())
m = int(input())
arr = [list(map(int, input().split())) for _ in range(n)]
# Create node linked lists from 2D array
list_of_nodes = create_node_list(arr)
# Create double linked list
double_linked_list = create_double_linked_list(list_of_nodes)
# Print the double linked list
print_double_linked_list(double_linked_list)
Digital Advanced Coding Questions
TCS Digital coding questions for advanced levels test not only your knowledge but also your efficiency in solving complex problems within tight time constraints. These questions often involve multiple layers of logic and optimization techniques. Here are a few sample advanced coding problems:
Problem | Topic | Approach |
---|---|---|
Implement a Least Recently Used (LRU) Cache using linked lists and hashmaps. | Data Structures (Linked List, HashMap) | Efficient use of space and time |
Find the longest increasing subsequence in a given array. | Dynamic Programming | Memoization, Recursion |
Given a binary tree, convert it into its mirror image. | Trees | Recursive Tree Manipulation |
Implement a system to schedule jobs on multiple processors using priority queues. | Greedy Algorithms | Queue Manipulation, Optimization |
Design an algorithm to find the maximum profit that can be made by buying and selling stocks. | Dynamic Programming, Greedy | Max Profit, Min Cost Calculation |
TCS Digital Coding Round Questions
The coding round for TCS Digital typically involves a mix of medium to high difficulty problems. Here is an example format of a typical coding round:
Question Type | Sample Question | Solution Approach |
---|---|---|
Medium-Level Algorithm | Find the second largest element in an unsorted array. | Use sorting or linear scan |
Advanced-Data Structure | Implement a priority queue using a min-heap. | Heap-based operations |
Dynamic Programming | Find the longest palindromic subsequence in a string. | DP table with memoization |
Greedy Algorithm | Schedule tasks with given deadlines and maximize profit. | Greedy method with sorting |
String Manipulation | Find the smallest window in a string containing all characters of another string. | Sliding window technique |
Digital Coding Questions for Freshers
While the coding questions for TCS Digital are challenging, they are also solvable with proper preparation. Freshers are typically expected to demonstrate a strong grasp of fundamental algorithms and data structures. Commonly asked coding questions for freshers include:
Question | Topic | Difficulty |
---|---|---|
Implement binary search on a sorted array. | Searching Algorithm | Easy |
Write a function to check if a string is a palindrome. | String Manipulation | Easy |
Reverse the elements of a linked list. | Linked List | Moderate |
Sort an array using merge sort. | Sorting Algorithms | Moderate |
Find the number of ways to reach the nth stair if you can climb either 1 or 2 steps at a time. | Dynamic Programming | Moderate |
How to Prepare for TCS Digital Coding Exam?
To succeed in TCS Digital coding rounds, you need to focus on understanding and practising core topics:
Preparation Strategy | Description |
---|---|
Master Data Structures & Algorithms | Study data structures like arrays, linked lists, trees, and algorithms such as sorting, searching, and graph traversal. |
Practice Dynamic Programming | Solve DP-based problems to build optimization skills. |
Time Management | Practice solving problems under timed conditions. |
Focus on Optimization | Practice reducing time and space complexity for efficient solutions. |
Disclaimer: While we have gathered as much information from TCS’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.
Conclusion
TCS Digital coding questions challenge candidates on multiple levels, requiring proficiency in algorithms, data structures, dynamic programming, and more. Whether you're a fresher or an experienced professional, thorough preparation and continuous practice of advanced coding problems are essential for cracking the TCS Digital coding round.
Use the past questions as practice and focus on time-bound solving to improve speed and accuracy. By mastering the essential topics and practising a variety of coding problems, you can significantly increase your chances of securing a role in TCS Digital.
Frequently Asked Questions (FAQs)
1. What is the difficulty level of coding questions in the TCS Digital exam?
The coding questions in TCS Digital range from moderate to advanced. They often test knowledge of algorithms, data structures, and problem-solving with an emphasis on optimization.
2. Which programming languages can I use in the TCS Digital coding round?
You can choose from popular languages such as C, C++, Java, Python, and sometimes JavaScript, depending on the platform used for the coding assessment.
3. How many coding questions are asked in the TCS Digital exam?
Typically, the TCS Digital exam includes 2-3 coding questions to be solved within 60 to 90 minutes.
4. What are the most common topics for TCS Digital coding questions?
The most common topics include dynamic programming, string manipulation, sorting and searching algorithms, graph theory, and data structures like arrays, trees, and linked lists.
5. How can I prepare for the TCS Digital advanced coding questions?
To prepare for advanced coding questions, focus on solving complex problems related to dynamic programming, graph algorithms, and system design. Practising on coding platforms like LeetCode and Codeforces can also be helpful.
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!
Login 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

Comments
Add comment