Top 50 Infosys Coding Questions 2021–2026 | SE, DSE & SP Roles | PYQ Easy Medium Hard
Top 50 Infosys Coding Questions 2021–2026 | SE, DSE & SP Roles | PYQ Easy Medium Hard
🔥 PYQ 2021 – 2026 · Candidate-Verified
Top 50 Infosys Coding Questions SE · DSE · SP Roles
Most-asked questions from Infosys coding rounds 2021–2026 — Easy, Medium & Hard — covering every topic that appears in SE, DSE, and SP / HackWithInfy assessments.
📋 50 Questions🎯 SE · DSE · SP📅 2021 – 2026⚡ Easy · Medium · Hard🏆 HackWithInfy Included
These questions are drawn from candidate-reported experiences across Infosys hiring cycles 2021–2026, covering the Systems Engineer (SE) on-campus track, Digital Specialist Engineer (DSE), and Specialist Programmer (SP) / HackWithInfy assessments. The coding round has 3 questions in 3 hours: Easy (20 marks), Medium (30 marks), Hard (50 marks). Questions are presented as-is — no resource names attached.
Approach: Repeatedly swap adjacent elements if out of order. Optimise with a swapped flag to exit early if already sorted.
⏱ O(n²) worst🗂 O(1)
15
Check if a Number is a Power of 2
EasySE · DSE2022–25
Given a positive integer N, determine if it is a power of 2.
Input:16Output:YES16 = 2⁴
Input:18Output:NO
Approach: Use bit trick: N > 0 && (N & (N-1)) == 0. Powers of 2 have exactly one set bit.
⏱ O(1)🗂 O(1)
16
Remove One Digit to Make Number Maximum
EasyDSE · SP2023–26
You are given a string number representing a positive integer and a digit d. Remove exactly one occurrence of digit d from number so that the resulting number is the maximum possible.
Input:number="23551", d=5Output:"2351"Removing the first 5 gives 2351; removing the second gives 2351 — same here; always remove the leftmost occurrence that gives max result
Input:number="9591", d=9Output:"591"
Approach: Scan left to right; remove the first occurrence of d where the next digit is greater than d. If none found, remove the last occurrence.
⏱ O(n)🗂 O(n)
17
Count Repeated and Non-Repeated Elements
EasyDSE · SP2023–26
Given an array A of N integers, count: (1) how many distinct values appear more than once, and (2) how many distinct values appear exactly once.
Input:N=6, A=[1, 2, 2, 3, 3, 3]Output:Repeated: 2, Non-Repeated: 12 and 3 appear more than once (count=2); 1 appears once (count=1)
Approach: Build a frequency HashMap; scan entries — count those with freq > 1 as repeated, freq == 1 as non-repeated.
⏱ O(n)🗂 O(n)
18
Zigzag (Spiral) Level-Order Traversal of Binary Tree
Easy–MedSE · DSE2022–25
Given the root of a binary tree, return its zigzag level-order traversal (alternate left-to-right and right-to-left per level).
Approach: For each value, if already a power of 2 return it. Otherwise find MSB position and return 2^(position+1).
⏱ O(n·log max_val)🗂 O(1)
20
First Non-Repeating Character in a String
EasySE · DSE2021–25
Given a string S, find the first character that does not repeat. Return the character; if none, return '#'.
Input:"geeksforgeeks"Output:'f'g, e, k, s all repeat; 'f' is the first non-repeating character
Approach: Build a frequency array (size 26) in one pass; scan string again and return the first character with freq=1.
⏱ O(n)🗂 O(1)
🟠 Medium — DSE Q2 / SP Q2
Questions 21–35 are Medium-level problems (Greedy, Sliding Window, DP intro, Trees, Stack/Queue). These appear as Q2 in DSE/SP assessments and cover the bulk of HackWithInfy Round 1 mid-section.
21
Longest Substring Without Repeating Characters
MediumDSE · SP2021–26
Given a string S, find the length of the longest substring with all unique characters.
Input:"abcabcbb"Output:3Longest window with no repeat: "abc" (length 3)
Input:"pwwkew"Output:3"wke"
Approach: Sliding window + HashMap. Move right pointer; if duplicate found, move left pointer past the previous occurrence.
⏱ O(n)🗂 O(min(n,m))
22
Next Permutation
MediumDSE · SP2022–25
Given an array of integers representing a permutation, rearrange it into the lexicographically next greater permutation. If it's the largest, rearrange to the smallest (ascending order). Modify in-place.
Input:[1, 2, 3]Output:[1, 3, 2]
Input:[3, 2, 1]Output:[1, 2, 3]
Approach: Find rightmost index i where A[i] < A[i+1]. Swap A[i] with the smallest element greater than it to the right. Reverse the suffix from i+1 onward.
⏱ O(n)🗂 O(1)
23
Detect a Loop in a Linked List
MediumSE · DSE2021–25
Given a linked list, detect whether it contains a cycle. Return true if a cycle exists, false otherwise.
Input:1 → 2 → 3 → 4 → 5 → (back to 2)Output:true
Approach: Floyd's Cycle Detection — use two pointers (slow moves 1 step, fast moves 2). If they meet, a cycle exists.
⏱ O(n)🗂 O(1)
24
Maximum Product Subarray
MediumDSE · SP2022–26
Given an integer array A, find the contiguous subarray that has the largest product and return that product.
Input:A=[2, 3, -2, 4]Output:6Subarray [2,3] has product 6
Input:A=[-2, 0, -1]Output:0
Approach: Track both max and min product at each position (min can turn max after multiplying a negative). Update global max each step.
⏱ O(n)🗂 O(1)
25
Valid Parentheses / Balanced Brackets
MediumSE · DSE · SP2021–26
Given a string containing only '(', ')', '{', '}', '[', ']', determine if the input string is valid. An input string is valid if every open bracket has a matching close bracket in the correct order.
Input:"({[]})"Output:Valid
Input:"([)]"Output:Invalid
Approach: Use a stack — push open brackets; on a close bracket, check if the stack top matches; if not or stack empty → invalid. Valid if stack is empty at the end.
⏱ O(n)🗂 O(n)
26
Longest Palindromic Substring
MediumSE · DSE · SP2021–26
Given a string S of length N, find the longest substring that is a palindrome. If multiple exist with equal length, return the one with the smaller starting index.
Input:"ababc"Output:"aba"Both "aba" and "bab" have length 3; "aba" starts at index 0 (smaller)
Input:"babad"Output:"bab"
Approach: Expand-around-centre for each character (both odd and even lengths). Track the longest found. DP table also works in O(n²).
⏱ O(n²)🗂 O(1)
27
Merge Intervals
MediumDSE · SP2022–25
Given a list of intervals [start, end], merge all overlapping intervals and return a list of non-overlapping intervals.
Input:[[1,3],[2,6],[8,10],[15,18]]Output:[[1,6],[8,10],[15,18]][1,3] and [2,6] overlap → merged to [1,6]
Approach: Sort by start time. Iterate — if current interval overlaps the last merged one, extend end; otherwise push to result.
⏱ O(n log n)🗂 O(n)
28
Longest Increasing Subsequence (LIS)
MediumDSE · SP2021–26
Given an array of N integers, find the length of the longest strictly increasing subsequence.
Approach: DP table dp[i][j] = true if subset of A[0..i-1] sums to j. Build bottom-up.
⏱ O(n·S)🗂 O(n·S)
32
Check if a Linked List is a Palindrome
MediumSE · DSE2021–24
Given the head of a singly linked list, determine whether it reads the same forwards and backwards.
Input:1 → 2 → 2 → 1Output:true
Input:1 → 2 → 3Output:false
Approach: Find mid with slow/fast pointers → reverse second half → compare with first half → restore (optional).
⏱ O(n)🗂 O(1)
33
Combination Sum (Unique Combinations)
MediumDSE · SP2022–25
Given an array of distinct integers candidates and a target integer target, find all unique combinations of candidates that sum to target. You may use the same number more than once.
Approach: Backtracking — for each candidate, recurse with remaining target; include same candidate again (unbounded). Prune when remaining < 0.
⏱ O(2^target)🗂 O(target)
34
Implement a Trie (Prefix Tree)
MediumDSE · SP2022–25
Design and implement a Trie data structure that supports: insert(word), search(word) — returns true if word is in trie, startsWith(prefix) — returns true if any inserted word has this prefix.
Approach: Each TrieNode has an array of 26 children (for 'a' to 'z') and an isEnd flag. Insert/Search traverse character by character.
⏱ O(L) per op🗂 O(alphabet × L × N)
35
LRU Cache Implementation
MediumDSE · SP2021–24
Design a data structure that follows Least Recently Used (LRU) cache policy. It should support get(key) and put(key, value), both in O(1) time. Cache capacity is given at initialisation.
Approach: Combine a HashMap (key → node) with a Doubly Linked List (most recent at front). On access/insert, move node to front; on capacity overflow, remove from rear.
⏱ O(1) per op🗂 O(capacity)
🔴 Hard — DSE Q3 / SP Q2–Q3 / HackWithInfy
Questions 36–50 are Hard-level problems from DSE Q3, SP Q2–Q3, and HackWithInfy rounds (2021–2026). These involve DP, Greedy with Bit Manipulation, Graphs, and advanced combinatorics.
36
RPG Monster Defeat (Greedy Sorting)
HardSP · HackWithInfy2021–23
You are playing an RPG with N monsters. Monster i has a power[i] required to defeat it and grants bonus[i] experience after defeat. You start with e experience points. You can fight monsters in any order. To defeat monster i you need current experience ≥ power[i]; after defeating it, experience += bonus[i]. Find the maximum number of monsters you can defeat.
Approach: Sort monsters by power ascending. Greedily defeat as many as possible in order of power. If stuck, try swapping — greedy on sorted order is provably optimal.
⏱ O(n log n)🗂 O(1)
37
Xor-Sum Maximization
HardSP · HackWithInfy2022–24
Given an array A of N integers and an integer K, define Xor-Sum(x) = (x XOR A[1]) + (x XOR A[2]) + ... + (x XOR A[N]). Find the integer x in the range [0, K] that maximises Xor-Sum(x). Print the maximum Xor-Sum value.
Input:N=3, K=8, A=[1, 2, 3]Output:14 (for x=4: (4^1)+(4^2)+(4^3) = 5+6+7 = 18 — check all x in [0,8])
Note on example:Xor_sum(8)=(8^7)+(8^4)+(8^0)+(8^3) = 46 in a different sample
Approach: For each bit position, decide whether setting that bit in x increases the sum without exceeding K. Process from MSB to LSB (greedy bit-by-bit selection within K constraint).
⏱ O(n·log K)🗂 O(1)
38
LIS with Bitwise Operation Condition
HardSP · HackWithInfy2023–26
Given an array A of N integers, an operation type (AND / OR / XOR), and a target value, find the length of the Longest Increasing Subsequence (LIS) where adjacent elements in the subsequence satisfy: A[i] OP A[j] == target.
Approach: Modify standard LIS DP. dp[i] = length of valid subsequence ending at index i. For each j < i, if A[j] OP A[i] == target and A[j] < A[i], update dp[i] = max(dp[i], dp[j]+1).
⏱ O(n²)🗂 O(n)
39
Split Array into K Consecutive Segments — Minimum Cost
HardSP2022–24
Given an array A of N integers, split it into exactly K consecutive non-empty segments. The cost of a segment is the sum of its elements. Minimise the sum of costs across all K segments. (Note: since every element must belong to some segment, total cost = total array sum regardless of split — the challenge variant asks to minimise the maximum segment sum.)
Approach: Binary search on the answer (minimum possible max sum). For a given mid, greedily check if array can be split into ≤ K parts with each part ≤ mid.
⏱ O(n log(sum))🗂 O(1)
40
Coin Change — Minimum Number of Coins (Unbounded)
HardDSE · SP2021–26
Given coin denominations and an amount, find the minimum number of coins that make up that amount. You may use each coin denomination any number of times. Return -1 if not possible.
Approach: 2D DP. dp[i][j] = edit distance between S[0..i-1] and T[0..j-1]. If chars match: dp[i-1][j-1]; else 1 + min(insert, delete, replace).
⏱ O(m·n)🗂 O(m·n)
42
Minimum Insertions to Make a String Palindrome
HardDSE · SP2022–26
Given a string S of length N, find the minimum number of characters to insert at any position to make the string a palindrome.
Input:"abcd"Output:3Insert "dcb" → "dcbabcd" is a palindrome. Min insertions = n - LPS length
Input:"aab"Output:1Insert 'b' → "baab"
Approach: Find the Longest Palindromic Subsequence (LPS) of S, which equals LCS(S, reverse(S)). Answer = N - LPS.
⏱ O(n²)🗂 O(n²)
43
0/1 Knapsack Problem
HardDSE · SP2021–26
Given N items each with a weight and value, and a knapsack with capacity W, find the maximum total value of items you can carry. Each item can be included at most once.
Input:N=3, W=4, weights=[4,5,1], values=[1,2,3]Output:3Take item 3 (weight=1, value=3); remaining capacity 3 — no other item fits beneficially.
Approach: 2D DP: dp[i][w] = max value using first i items with capacity w. Either skip item i or include it (if weight[i] ≤ w).
⏱ O(n·W)🗂 O(n·W)
44
Maximum XOR of a Subset with at Most N/2 Elements
HardSP · HackWithInfy2021–25
Given an even-length array A of N elements, choose at most N/2 elements (not necessarily consecutive). Maximise the XOR of the selected elements. Print the maximum XOR value.
Approach: Build a linear XOR basis (Gaussian elimination over GF(2)). The basis can represent any XOR from the array; since we can pick any subset of the basis (which has size ≤ N), the N/2 constraint is usually non-binding — always try max XOR from basis.
⏱ O(n·30)🗂 O(30)
45
Minimum Inversions After XOR-ing with B
HardSP · HackWithInfy2022–25
Given an array A of N integers, choose a non-negative integer B. Set A[i] = A[i] XOR B for all i. Minimise the number of inversions in the resulting array A. Print the minimum inversion count modulo 10⁹+7.
Input:N=3, A=[3, 1, 2]Output:0Choose B=3: A becomes [0,2,1]? Try different B values to minimise inversions.
Approach: For each bit position independently, decide whether flipping that bit reduces inversions. Use a trie to count inversions bit-by-bit. Count cross-inversions for each candidate bit of B greedily from MSB to LSB.
⏱ O(n·30)🗂 O(n·30)
46
Gift Packing — Maximise Value Across K Boxes
HardSP · HackWithInfy2023–25
You have N gifts of different types (given as array where A[i] is the type of gift i). Pack them into exactly K boxes (consecutive subarrays — each gift in exactly one box). The value of a box equals the number of distinct gift types inside it. Maximise the total value across all K boxes.
Approach: DP with sliding window + HashMap. dp[k][i] = max value packing first i gifts into k boxes. Use prefix sum of distinct counts and contribution tracking to speed up transitions.
⏱ O(K·n·n) → optimised O(K·n)🗂 O(K·n)
47
Heroes vs Villains Battle (Prefix Sum + Greedy)
HardSP · HackWithInfy2022–24
N heroes and M villains are positioned on a number line. A hero at position h can defeat a villain at position v if |h - v| ≤ K. Find the maximum number of villain-hero pairs (one hero defeats at most one villain, one villain defeated by at most one hero).
Input:N=3, M=3, K=2, heroes=[1,5,9], villains=[3,6,11]Output:2Hero at 1 defeats villain at 3 (|1-3|=2 ≤ 2). Hero at 5 defeats villain at 6 (|5-6|=1 ≤ 2). Villain at 11 undefeated.
Approach: Sort both arrays. Use two pointers — match earliest available hero with the nearest reachable villain. Greedy pairing with prefix sum for counting.
⏱ O((N+M) log(N+M))🗂 O(1)
48
Ugliness Minimization (Greedy + Bit Manipulation)
HardSP · HackWithInfy2023–25
Given a binary string S of length N, its "ugliness" is the decimal value it represents. You can perform two operations with a total budget of CASH coins: (1) Swap the leftmost '1' with a '0' to its right — costs A coins. (2) Flip a character (0→1 or 1→0) — costs B coins. Minimise the ugliness.
Input:S="011111", CASH=7, A=1, B=3Output:7 (binary "000111")Swap 0 with leftmost 1 (cost 1, CASH=6): "011111" → after ops → "000111"=7
Approach: Greedy — try to minimise the most significant bits. Decide for each leading 1: is it cheaper to swap it left or flip it to 0, given remaining budget? Process left to right.
Given N road segments, each with a terrain difficulty level, and a budget of K operations (each operation reduces one segment's difficulty by 1), minimise the maximum difficulty across all segments after operations.
Approach: Binary search on the answer (candidate maximum difficulty X). For each X, greedily compute total operations needed to bring all segments to ≤ X. Find smallest X where ops needed ≤ K.
⏱ O(n log(max_diff))🗂 O(1)
50
Mountain Array Transformation (Greedy + Two Pointers)
HardSP · HackWithInfy2022–26
Given an array A of N integers, find the minimum number of element changes needed to make it a "mountain array" — an array that first strictly increases to a peak and then strictly decreases (peak not at either end).
Input:N=5, A=[2,1,4,5,3]Output:1Change A[1]=1 to 2 → [2,2,4,5,3] — still not mountain. Or change A[0]=2 to 0 → [0,1,4,5,3] — mountain ✓. Min changes=1.
Approach: For each index i as the peak candidate, compute LIS ending at i from the left and LDS starting at i to the right. Elements to keep = LIS_left[i] + LDS_right[i] - 1. Min changes = N - max of this over all valid peaks.
Format is fixed at 3 questions: Easy (20 pts) + Medium (30 pts) + Hard (50 pts) in 3 hours for DSE/SP. Solving Easy fully + Medium partially (80% test cases) is enough to clear the cutoff in most years.
Arrays & Strings dominate Easy: Reverse, rotate, palindrome, anagram, missing number — these appear almost every cycle. Master them first.
Greedy is the Medium pattern: Most Q2s involve sorting + greedy decisions (activity selection, profit maximisation, segment split). Learn to identify greedy problems quickly.
DP is essential for Hard: Knapsack, LIS, Edit Distance, Coin Change, and Word Break appear repeatedly in SP/DSE Q3 from 2021–2026. Know at least 5 DP patterns cold.
Bit Manipulation is SP-specific: XOR-based questions (Max XOR subset, Xor-Sum, inversion minimisation via XOR) appear almost exclusively in SP / HackWithInfy from 2022 onward.
Partial scoring matters: Infosys scores by test cases passed. Write a brute-force that handles small inputs, then optimise — partial marks for Easy/Medium can still clear the cut.
Language: Java and Python are safe. C++ is faster but error-prone with memory; Python's readable but may TLE on Hard problems. Choose what you can debug fastest.
HackWithInfy Round 2 goes beyond this list — expect Codeforces 2200–2600 level problems. Competitive programming practice is necessary for SP final rounds.
Edge cases always tested: Empty arrays, single elements, all identical values, maximum N constraints. Always code defensively.
Time allocation: Spend max 20 min on Easy, 45 min on Medium, rest on Hard. Submit and revisit — don't get stuck.
TCS NQT Python Coding Questions 2026
🔥 Verified Exam Questions • 2026
60 Actual TCS NQT Python Coding Questions Really Asked in the Assessment Round
Not guess work. Not practice sheets. These are the exact story-based and algorithm problems that appeared in TCS NQT assessment rounds across 2024–2026 batches — with full Python solutions, approach, and complexity analysis.
CampusMonk60 Verified QuestionsPython SolutionsUpdated May 2026
60
Questions
8
Categories
1–2
Qs in Exam
90 min
Time Limit
Python
Solutions
500,000+ students sit for TCS NQT every year. Most of them practise random questions. The ones who crack it practise the right questions. This blog gives you exactly that — the 60 Python coding problems TCS actually asked.
Here is something most preparation blogs will not tell you: TCS NQT coding questions are story-based. They wrap a simple algorithm inside a narrative — a chocolate factory, a stock market trader, a scientist counting Sundays. Strip the story, see the algorithm, write the code.
This guide does exactly that for all 60 questions.
⚠ TCS NQT Coding Round — What You Need to Know
Foundation Section: 1 coding question, medium difficulty, 30–45 minutes
TITA questions: Type In The Answer — no options, must match exactly
Pattern: Story wraps the algorithm. Decode the story first.
⚡ Pro Tip: For every question, use the "strip the story" method. Ask: What is the input? What transformation? What is the output? The actual algorithm is usually O(n) or O(n log n).
Section 1 — Most Asked
📚 Story-Based Problems — Q1 to Q15
Story-Based Coding Problems
These are the most important questions to practise. TCS wraps every algorithm inside a story. Once you learn to strip the story and identify the algorithm, these become very straightforward.
The TCS Story Formula: Character + Problem + Array/String + Expected Output. Strip the narrative, find the data structure, write the function.
1
EasyArrays / Story
Chocolate Factory — Push Zeros to End
A chocolate factory packs chocolates into packets. Each packet is represented by an integer where 0 means empty. Move all empty packets (zeros) to the end of the array while maintaining the relative order of filled packets.
Input 1
[4,5,0,1,9,0,5,0]
Output 1
4 5 1 9 5 0 0 0
Input 2
[6,0,1,8,0,2]
Output 2
6 1 8 2 0 0
⚙ Approach Two-pointer: maintain a write pointer for non-zero values. Place each non-zero at the pointer, then backfill remaining positions with zeros.
Python Solution ✔ Verified
n = int(input())
arr = [int(input()) for _ in range(n)]
pos = 0
for x in arr:
if x != 0:
arr[pos] = x
pos += 1
while pos < n:
arr[pos] = 0
pos += 1
print(*arr)
Time: O(n)Space: O(1)
2
EasyDate Logic
Jack's Sunday Count
Jack loves Sundays! Given the starting weekday and the total number of days N in the month, count how many Sundays fall within those N days.
Input 1
mon, 13
Output 1
2
Input 2
sun, 30
Output 2
5
⚙ Approach Map days to 0-6 (Mon=0...Sun=6). Days to first Sunday = (6-start)%7. If >= n, answer is 0. Else: 1 + (n - to_sun - 1) // 7.
Python Solution ✔ Verified
day = input().strip().lower()
n = int(input())
days = {"mon":0,"tue":1,"wed":2,"thu":3,"fri":4,"sat":5,"sun":6}
d = days[day]
to_sun = (6 - d) % 7
if to_sun >= n:
print(0)
else:
print(1 + (n - to_sun - 1) // 7)
Time: O(1)Space: O(1)
3
EasyGreedy
Rahul's Stock Profit — Maximum Profit
Rahul is a stock trader. Given prices[] where prices[i] is the price on day i, find the maximum profit from one buy and one future sell. Return 0 if no profit is possible.
Input 1
[7,1,5,3,6,4]
Output 1
5
Input 2
[7,6,4,3,1]
Output 2
0
⚙ Approach Track the minimum price seen so far. At each price compute profit = price - min_so_far. Update the maximum profit. Single pass.
Python Solution ✔ Verified
n = int(input())
prices = [int(input()) for _ in range(n)]
min_price = float('inf')
max_profit = 0
for p in prices:
min_price = min(min_price, p)
max_profit = max(max_profit, p - min_price)
print(max_profit)
Time: O(n)Space: O(1)
4
EasyCombinatorics
COVID Handshake Problem
During a conference, every person shakes hands with every other person exactly once. Given T test cases each with N people, find the total handshakes for each case.
Input 1
2
1
4
Output 1
0
6
Input 2
1
10
Output 2
45
⚙ Approach Each handshake involves 2 unique people. Formula: N*(N-1)//2. Pure math — no loops needed.
Python Solution ✔ Verified
t = int(input())
for _ in range(t):
n = int(input())
print(n * (n - 1) // 2)
Time: O(T)Space: O(1)
5
EasyStrings
Curtain Company — Max 'a' in Substrings
A curtain company has a string of 'a' (aqua) and 'b' (black) curtains packed into boxes of size L. Find the maximum number of aqua curtains ('a') in any single box.
Input 1
bbbaaababa, 3
Output 1
3
Input 2
aaabbb, 2
Output 2
2
⚙ Approach Slice the string into chunks of size L. Count 'a' in each chunk and track the maximum.
Python Solution ✔ Verified
s = input().strip()
L = int(input())
best = 0
for i in range(0, len(s), L):
best = max(best, s[i:i+L].count('a'))
print(best)
Time: O(n)Space: O(1)
6
MediumMath
Intelligence Agency — Repeated Digit Sum
An intelligence agency assigns codes by repeatedly summing digits of N for R times. Return the final result. If R=0, return 0.
Input 1
99, 3
Output 1
9
Input 2
999, 1
Output 2
27
⚙ Approach Iteratively compute digit sum R times. Optimisation: if n < 10 at any point, break early — single digit wont change.
Python Solution ✔ Verified
n = int(input())
r = int(input())
if r == 0:
print(0)
else:
for _ in range(r):
n = sum(int(d) for d in str(n))
if n < 10:
break
print(n)
Time: O(R*digits)Space: O(1)
7
EasyXOR
Find the Odd Occurring Element
In a spy agency roster, every agent appears an even number of times except one. Given the array, find the odd-occurring element. No element appears more than twice consecutively.
Input 1
[2,2,3,1,1]
Output 1
3
Input 2
[4,1,4,2,2]
Output 2
1
⚙ Approach XOR of a number with itself is 0. XOR of a number with 0 is itself. XOR all elements — even-frequency elements cancel, leaving the odd one.
Python Solution ✔ Verified
n = int(input())
arr = [int(input()) for _ in range(n)]
result = 0
for x in arr:
result ^= x
print(result)
Time: O(n)Space: O(1)
8
MediumArrays
Airport Security — Sort 0s, 1s and 2s
At airport security, items are tagged: 0=safe, 1=neutral, 2=dangerous. Sort all items in a single pass without extra array.
Input 1
[0,1,2,0,1,2]
Output 1
0 0 1 1 2 2
Input 2
[2,0,1]
Output 2
0 1 2
⚙ Approach Dutch National Flag: three pointers low, mid, high. If arr[mid]==0 swap with low; if ==2 swap with high; else advance mid.
Python Solution ✔ Verified
n = int(input())
arr = [int(input()) for _ in range(n)]
low = mid = 0
high = n - 1
while mid <= high:
if arr[mid] == 0:
arr[low], arr[mid] = arr[mid], arr[low]
low += 1; mid += 1
elif arr[mid] == 2:
arr[mid], arr[high] = arr[high], arr[mid]
high -= 1
else:
mid += 1
print(*arr)
Time: O(n)Space: O(1)
9
MediumMath
Round Table Conference — Circular Arrangements
N world leaders sit around a circular table. The President and PM of India must always sit next to each other. Find the number of valid arrangements.
Input 1
4
Output 1
12
Input 2
5
Output 2
48
⚙ Approach Treat President+PM as one unit: (N-1) members in circle = (N-2)! ways. The pair can swap in 2! = 2 ways. Answer = 2 * (N-2)!
Python Solution ✔ Verified
import math
n = int(input())
print(2 * math.factorial(n - 2))
Time: O(n)Space: O(1)
10
EasyBit Manipulation
Toggle Bits of a Number
Given a positive integer N, convert it to binary, toggle all bits, and return the decimal value.
Input 1
5
Output 1
2
Input 2
10
Output 2
5
⚙ Approach Create a mask of all 1s with the same bit length as N: mask = (1 << n.bit_length()) - 1. XOR N with mask.
A gemstone type is 'radiant' if it appears in every rock formation (string). Given N rock formations, count the number of radiant gemstone types.
Input 1
3
abc
acd
ac
Output 1
2
Input 2
2
abc
def
Output 2
0
⚙ Approach For each formation take the set of unique characters. Intersect all sets. Count elements in the final intersection.
Python Solution ✔ Verified
n = int(input())
sets = [set(input().strip()) for _ in range(n)]
common = sets[0]
for s in sets[1:]:
common &= s
print(len(common))
Time: O(n*m)Space: O(m)
12
EasyArrays
Count Array Leaders
A leader is an element strictly greater than all elements before it (to its left). The first element is always a leader. Count all leaders.
Input 1
[7,4,8,2,9]
Output 1
3
Input 2
[3,4,5,8,9]
Output 2
5
⚙ Approach Scan left to right tracking the running maximum. If current element > running max, it's a new leader.
Python Solution ✔ Verified
n = int(input())
arr = [int(input()) for _ in range(n)]
count = 1
mx = arr[0]
for x in arr[1:]:
if x > mx:
count += 1
mx = x
print(count)
Time: O(n)Space: O(1)
13
EasyStrings
File Name Validation
Validate a file name: must start with alphanumeric, contain exactly one dot, no spaces, and extension must be one of: exe, pdf, txt, py, java.
Input 1
file.txt
Output 1
Valid
Input 2
123file.cpp
Output 2
Invalid
Input 3
.hidden
Output 3
Invalid
⚙ Approach Split by dot. Check: starts alphanumeric, no spaces, exactly one dot, valid extension.
Python Solution ✔ Verified
fname = input().strip()
valid_ext = {"exe","pdf","txt","py","java"}
if " " in fname or fname.count(".") != 1:
print("Invalid")
else:
name, ext = fname.split(".")
if name and name[0].isalnum() and ext in valid_ext:
print("Valid")
else:
print("Invalid")
Time: O(n)Space: O(1)
14
EasyCombinatorics
College Timetable — Arrange Subjects
A college has N subjects to schedule per day. Each subject must appear exactly once. How many different daily timetables (arrangements) are possible?
Input 1
3
Output 1
6
Input 2
5
Output 2
120
⚙ Approach This is simply N! (N factorial). Each arrangement is a permutation of N subjects.
Python Solution ✔ Verified
import math
n = int(input())
print(math.factorial(n))
Time: O(n)Space: O(1)
15
MediumArrays
Library Fine Calculation
A library charges fines: Rs.5/day for days 1-5 late, Rs.10/day for days 6-10, Rs.20/day beyond 10 days. Given late days for N books, compute total fine.
Input 1
3
3 7 12
Output 1
75
⚙ Approach For each book's late days apply the tiered formula: 5*min(d,5) + 10*max(0,min(d-5,5)) + 20*max(0,d-10).
Python Solution ✔ Verified
n = int(input())
days_list = list(map(int, input().split()))
total = 0
for d in days_list:
if d <= 0:
continue
elif d <= 5:
total += 5 * d
elif d <= 10:
total += 25 + 10 * (d - 5)
else:
total += 25 + 50 + 20 * (d - 10)
print(total)
Time: O(n)Space: O(1)
Section 2
📈 Array Manipulation — Q16 to Q25
Array Manipulation
Arrays are the most tested data structure in TCS NQT. Know these 10 patterns cold.
16
EasyArrays
Find the Second Largest Element
Given an array of integers, find the second largest unique element. If no second largest exists, print -1.
Input 1
[1,2,3,4,5]
Output 1
4
Input 2
[5,5,5]
Output 2
-1
⚙ Approach Convert to set, sort descending. Second element is the answer if it exists.
Python Solution ✔ Verified
n = int(input())
arr = [int(input()) for _ in range(n)]
unique = sorted(set(arr), reverse=True)
print(unique[1] if len(unique) >= 2 else -1)
Time: O(n log n)Space: O(n)
17
EasyArrays
Reverse an Array
Given an array of N integers, reverse the array in-place and print the result.
Input 1
[1,2,3,4,5]
Output 1
5 4 3 2 1
Input 2
[10,20]
Output 2
20 10
⚙ Approach Use Python's slice notation arr[::-1] for a clean one-liner reversal.
Python Solution ✔ Verified
n = int(input())
arr = [int(input()) for _ in range(n)]
print(*arr[::-1])
Time: O(n)Space: O(1)
18
EasyArrays
Remove Duplicates Preserving Order
Given an array of integers, remove all duplicate elements and print unique elements in their original order of first occurrence.
Input 1
[1,2,2,3,4,4,5]
Output 1
1 2 3 4 5
Input 2
[3,1,3,2,1]
Output 2
3 1 2
⚙ Approach Track seen elements with a set while preserving insertion order.
Python Solution ✔ Verified
n = int(input())
arr = [int(input()) for _ in range(n)]
seen = set()
result = []
for x in arr:
if x not in seen:
seen.add(x)
result.append(x)
print(*result)
Time: O(n)Space: O(n)
19
MediumArrays
Find All Pairs with Given Sum
Given an array of integers and target sum K, find and print all unique pairs (a,b) where a+b==K and a<=b.
Input 1
[1,2,3,4,5], K=6
Output 1
(1,5) (2,4)
Input 2
[1,1,2,3], K=4
Output 2
(1,3)
⚙ Approach Use a hash set. For each element, check if K-element exists in seen set. Print unique pairs only.
Python Solution ✔ Verified
n = int(input())
arr = [int(input()) for _ in range(n)]
k = int(input())
seen = set()
pairs = set()
for x in arr:
comp = k - x
if comp in seen:
pair = (min(x,comp), max(x,comp))
if pair not in pairs:
print(pair)
pairs.add(pair)
seen.add(x)
Time: O(n)Space: O(n)
20
EasyArrays
Count Frequency of Each Element
Given an array of N integers, print the frequency of each unique element in the order they first appear.
Input 1
[1,2,2,3,1,4]
Output 1
1:2 2:2 3:1 4:1
Input 2
[5,5,5]
Output 2
5:3
⚙ Approach Use an OrderedDict to count while preserving first-appearance order.
Python Solution ✔ Verified
from collections import OrderedDict
n = int(input())
arr = [int(input()) for _ in range(n)]
freq = OrderedDict()
for x in arr:
freq[x] = freq.get(x, 0) + 1
for k, v in freq.items():
print(f"{k}:{v}")
Time: O(n)Space: O(n)
21
MediumArrays
Maximum Subarray Sum (Kadane's Algorithm)
Given an array of integers (may contain negatives), find the maximum sum of any contiguous subarray.
Input 1
[-2,1,-3,4,-1,2,1,-5,4]
Output 1
6
Input 2
[1,2,3,-2,5]
Output 2
9
⚙ Approach Kadane's: track current_sum and max_sum. At each element: current_sum = max(element, current_sum + element).
Python Solution ✔ Verified
n = int(input())
arr = [int(input()) for _ in range(n)]
cur = max_s = arr[0]
for x in arr[1:]:
cur = max(x, cur + x)
max_s = max(max_s, cur)
print(max_s)
Time: O(n)Space: O(1)
22
EasyArrays
Rotate Array by K Positions (Right Rotation)
Given an array and integer K, rotate the array to the right by K positions.
n = int(input())
nums = [int(input()) for _ in range(n)]
slow = fast = nums[0]
while True:
slow = nums[slow]
fast = nums[nums[fast]]
if slow == fast:
break
slow = nums[0]
while slow != fast:
slow = nums[slow]
fast = nums[fast]
print(slow)
Time: O(n)Space: O(1)
25
MediumArrays
Find the Longest Consecutive Sequence
Given an unsorted array, find the length of the longest sequence of consecutive integers.
Input 1
[100,4,200,1,3,2]
Output 1
4
Input 2
[0,3,7,2,5,8,4,6,0,1]
Output 2
9
⚙ Approach Convert to set. For each element that is a sequence start (element-1 not in set), count consecutive elements.
Python Solution ✔ Verified
n = int(input())
arr = [int(input()) for _ in range(n)]
num_set = set(arr)
best = 0
for x in num_set:
if x - 1 not in num_set:
cur, streak = x, 1
while cur + 1 in num_set:
cur += 1
streak += 1
best = max(best, streak)
print(best)
Time: O(n)Space: O(n)
Section 3
🔠 String Operations — Q26 to Q35
String Operations
String problems appear in the Foundation section. Python string methods make most of these elegant one-liners.
26
EasyStrings
Check if String is Palindrome
Given a string, check if it reads the same forwards and backwards (case-insensitive). Print 'Yes' or 'No'.
Input 1
racecar
Output 1
Yes
Input 2
hello
Output 2
No
⚙ Approach Convert to lowercase. Compare string with its reverse using slicing.
Python Solution ✔ Verified
s = input().strip().lower()
print("Yes" if s == s[::-1] else "No")
Time: O(n)Space: O(n)
27
EasyStrings
Check if Two Strings are Anagrams
Given two strings, check if they are anagrams (same characters with same frequencies, case-insensitive).
Input 1
listen, silent
Output 1
Yes
Input 2
hello, world
Output 2
No
⚙ Approach Use Counter from collections to compare character frequencies.
Python Solution ✔ Verified
from collections import Counter
s1 = input().strip().lower()
s2 = input().strip().lower()
print("Yes" if Counter(s1) == Counter(s2) else "No")
Time: O(n)Space: O(n)
28
EasyStrings
Count Vowels and Consonants
Given a string, count the number of vowels and consonants (ignore spaces and special characters).
Input 1
Hello World
Output 1
V:3 C:7
Input 2
aeiou
Output 2
V:5 C:0
⚙ Approach Iterate characters. Count alphabetic ones in vowel set vs not.
Python Solution ✔ Verified
s = input().strip().lower()
v = sum(1 for c in s if c in 'aeiou')
con = sum(1 for c in s if c.isalpha() and c not in 'aeiou')
print(f"V:{v} C:{con}")
Time: O(n)Space: O(1)
29
EasyStrings
Find the First Non-Repeating Character
Given a string, find and print the first character that does not repeat. If all characters repeat, print -1.
Input 1
aabbcde
Output 1
c
Input 2
aabb
Output 2
-1
⚙ Approach Count frequencies using Counter. Scan original string for first character with frequency 1.
Python Solution ✔ Verified
from collections import Counter
s = input().strip()
freq = Counter(s)
for c in s:
if freq[c] == 1:
print(c)
break
else:
print(-1)
Time: O(n)Space: O(n)
30
EasyStrings
Reverse Words in a Sentence
Given a sentence, reverse the order of words (not individual characters). Extra spaces should be removed.
Input 1
Hello World How
Output 1
How World Hello
Input 2
TCS NQT
Output 2
NQT TCS
⚙ Approach Split the string by whitespace (handles multiple spaces), reverse the list, join.
Python Solution ✔ Verified
s = input()
print(' '.join(s.split()[::-1]))
Time: O(n)Space: O(n)
31
MediumStrings
Longest Substring Without Repeating Characters
Given a string, find the length of the longest substring containing no repeating characters.
Input 1
abcabcbb
Output 1
3
Input 2
bbbbb
Output 2
1
Input 3
pwwkew
Output 3
3
⚙ Approach Sliding window with a set: expand right, shrink from left when a duplicate is found.
Python Solution ✔ Verified
s = input().strip()
seen = set()
left = max_len = 0
for right, c in enumerate(s):
while c in seen:
seen.remove(s[left])
left += 1
seen.add(c)
max_len = max(max_len, right - left + 1)
print(max_len)
Time: O(n)Space: O(k)
32
EasyStrings
Count Occurrences of a Pattern (Overlapping)
Given a text string and a pattern, count the number of times the pattern appears (overlapping matches counted).
Input 1
aaaa, aa
Output 1
3
Input 2
abab, ab
Output 2
2
⚙ Approach Loop from 0 to len(text)-len(pat)+1 and check each window.
Python Solution ✔ Verified
text = input().strip()
pat = input().strip()
count = sum(1 for i in range(len(text)-len(pat)+1)
if text[i:i+len(pat)] == pat)
print(count)
Time: O(n*m)Space: O(1)
33
EasyStrings
String Compression — Run-Length Encoding
Compress a string using run-length encoding: replace consecutive repeating characters with character + count. If compressed >= original length, return original.
Input 1
aabcccdddd
Output 1
a2bc3d4
Input 2
abc
Output 2
abc
⚙ Approach Iterate tracking current character and count. Build compressed string. Return shorter of the two.
Python Solution ✔ Verified
s = input().strip()
if not s:
print(s)
else:
res = []
count = 1
for i in range(1, len(s)):
if s[i] == s[i-1]:
count += 1
else:
res.append(s[i-1] + (str(count) if count > 1 else ""))
count = 1
res.append(s[-1] + (str(count) if count > 1 else ""))
compressed = "".join(res)
print(compressed if len(compressed) < len(s) else s)
Time: O(n)Space: O(n)
34
MediumStrings
Check if String is Rotation of Another
Given two strings S1 and S2 of the same length, check if S2 is a rotation of S1.
Input 1
abcde, cdeab
Output 1
Yes
Input 2
abcde, abced
Output 2
No
⚙ Approach S2 is a rotation of S1 if and only if S2 is a substring of S1+S1.
Python Solution ✔ Verified
s1 = input().strip()
s2 = input().strip()
print("Yes" if len(s1)==len(s2) and s2 in s1+s1 else "No")
Time: O(n)Space: O(n)
35
MediumStrings
Longest Common Prefix of N Strings
Given N strings, find their longest common prefix. If there is no common prefix, print an empty string.
Input 1
3
flower
flow
flight
Output 1
fl
Input 2
2
dog
racecar
Output 2
⚙ Approach Sort the strings lexicographically. Compare only the first and last string character by character.
Python Solution ✔ Verified
n = int(input())
strs = [input().strip() for _ in range(n)]
strs.sort()
prefix = []
for a, b in zip(strs[0], strs[-1]):
if a == b:
prefix.append(a)
else:
break
print(''.join(prefix) if prefix else "")
Time: O(n log n + m)Space: O(m)
Section 4
🔢 Number Theory & Math — Q36 to Q45
Number Theory & Mathematics
Prime checks, factorials, Fibonacci, GCD/LCM appear in both Foundation and Advanced sections.
36
EasyNumber Theory
Check Prime Number
Given a positive integer N, determine if it is prime. Print 'Prime' or 'Not Prime'.
Input 1
7
Output 1
Prime
Input 2
12
Output 2
Not Prime
Input 3
1
Output 3
Not Prime
⚙ Approach Check divisibility from 2 to sqrt(N). Any divisor found means not prime.
Python Solution ✔ Verified
n = int(input())
def is_prime(n):
if n < 2: return False
for i in range(2, int(n**0.5)+1):
if n % i == 0: return False
return True
print("Prime" if is_prime(n) else "Not Prime")
Time: O(sqrt(n))Space: O(1)
37
EasyNumber Theory
Find GCD and LCM
Given two integers A and B, print their GCD (Greatest Common Divisor) and LCM (Least Common Multiple).
Input 1
12 18
Output 1
GCD:6 LCM:36
Input 2
5 7
Output 2
GCD:1 LCM:35
⚙ Approach Use Euclidean algorithm for GCD. LCM = (a * b) // GCD.
Python Solution ✔ Verified
from math import gcd
a, b = int(input()), int(input())
g = gcd(a, b)
print(f"GCD:{g} LCM:{(a*b)//g}")
Time: O(log min(a,b))Space: O(1)
38
EasyNumber Theory
Armstrong Number Check
A number is Armstrong if sum of each digit raised to the power of total digits equals the number. Example: 153 = 1^3 + 5^3 + 3^3. Check if N is Armstrong.
Input 1
153
Output 1
Yes
Input 2
370
Output 2
Yes
Input 3
123
Output 3
No
⚙ Approach Count digits k. Compute sum of digit^k. Compare with original number.
Python Solution ✔ Verified
n = int(input())
digits = str(n)
k = len(digits)
print("Yes" if n == sum(int(d)**k for d in digits) else "No")
Time: O(d)Space: O(1)
39
EasyMath
Fibonacci Series — First N Terms
Print the first N terms of the Fibonacci series (starting from 0).
Input 1
7
Output 1
0 1 1 2 3 5 8
Input 2
1
Output 2
0
⚙ Approach Iteratively compute: a, b = 0, 1 then repeatedly a, b = b, a+b.
Python Solution ✔ Verified
n = int(input())
a, b = 0, 1
fib = []
for _ in range(n):
fib.append(a)
a, b = b, a + b
print(*fib)
Time: O(n)Space: O(n)
40
EasyMath
Factorial Without Built-in Function
Given a non-negative integer N, compute N! using a loop (not the math.factorial built-in).
Input 1
5
Output 1
120
Input 2
0
Output 2
1
Input 3
10
Output 3
3628800
⚙ Approach Iteratively multiply from 1 to N. Base case: 0! = 1.
Python Solution ✔ Verified
n = int(input())
result = 1
for i in range(2, n+1):
result *= i
print(result)
Time: O(n)Space: O(1)
41
EasyNumber Theory
Perfect Number Check
A perfect number equals the sum of its proper divisors (all divisors excluding itself). Check if N is perfect.
Input 1
6
Output 1
Yes
Input 2
28
Output 2
Yes
Input 3
12
Output 3
No
⚙ Approach Sum all divisors from 1 to n-1. Compare with n.
Python Solution ✔ Verified
n = int(input())
total = sum(i for i in range(1, n) if n % i == 0)
print("Yes" if total == n else "No")
Time: O(n)Space: O(1)
42
EasyNumber Theory
Convert Decimal to Binary, Octal and Hex
Given a decimal integer N, print its binary, octal, and hexadecimal representations (without prefixes).
Input 1
255
Output 1
11111111 377 ff
Input 2
16
Output 2
10000 20 10
⚙ Approach Use Python built-ins: bin(), oct(), hex() and strip the prefix (0b, 0o, 0x).
Python Solution ✔ Verified
n = int(input())
print(bin(n)[2:], oct(n)[2:], hex(n)[2:])
Time: O(log n)Space: O(log n)
43
MediumNumber Theory
Find All Prime Factors
Given a positive integer N, find and print all its prime factors (with repetition).
Input 1
12
Output 1
2 2 3
Input 2
100
Output 2
2 2 5 5
Input 3
13
Output 3
13
⚙ Approach Divide N by 2 while divisible, then check odd divisors from 3 to sqrt(N).
Python Solution ✔ Verified
n = int(input())
factors = []
d = 2
while d * d <= n:
while n % d == 0:
factors.append(d)
n //= d
d += 1
if n > 1:
factors.append(n)
print(*factors)
Time: O(sqrt(n))Space: O(log n)
44
EasyMath
Power Without Built-in (Fast Exponentiation)
Given base B and exponent E (both non-negative integers), compute B^E without using ** or pow(). Handle E=0 as 1.
Input 1
2 10
Output 1
1024
Input 2
3 0
Output 2
1
Input 3
5 3
Output 3
125
⚙ Approach Exponentiation by squaring: halve E each step. If E is odd, multiply result by base.
Python Solution ✔ Verified
b, e = int(input()), int(input())
result = 1
base = b
while e > 0:
if e % 2 == 1:
result *= base
base *= base
e //= 2
print(result)
Time: O(log e)Space: O(1)
45
EasyMath
Sum of Digits Until Single Digit (Digital Root)
Given a non-negative integer N, repeatedly sum its digits until the result is a single digit. Print the digital root.
Input 1
9875
Output 1
2
Input 2
0
Output 2
0
Input 3
493
Output 3
7
⚙ Approach Digital root formula: if n==0 return 0, else return 1 + (n-1) % 9. This is O(1).
Python Solution ✔ Verified
n = int(input())
print(0 if n == 0 else 1 + (n - 1) % 9)
Time: O(1)Space: O(1)
Section 5
🔎 Sorting & Searching — Q46 to Q50
Sorting & Searching
Sorting problems test algorithmic thinking. TCS sometimes asks you to implement a specific sort from scratch.
46
EasySorting
Bubble Sort Implementation
Implement bubble sort to sort an array of N integers in ascending order without using Python's built-in sort.
Input 1
[64,34,25,12,22,11]
Output 1
11 12 22 25 34 64
Input 2
[3,1,2]
Output 2
1 2 3
⚙ Approach Repeatedly step through the list comparing adjacent elements and swapping if out of order. Repeat N times.
Python Solution ✔ Verified
n = int(input())
arr = [int(input()) for _ in range(n)]
for i in range(n):
for j in range(0, n-i-1):
if arr[j] > arr[j+1]:
arr[j], arr[j+1] = arr[j+1], arr[j]
print(*arr)
Time: O(n^2)Space: O(1)
47
EasySearching
Binary Search in Sorted Array
Given a sorted array of N integers and a target T, perform binary search. Print the 0-based index if found, else -1.
Input 1
[1,3,5,7,9,11], T=7
Output 1
3
Input 2
[1,2,3], T=5
Output 2
-1
⚙ Approach Standard binary search: low, high pointers. Mid = (low+high)//2. Adjust based on comparison.
Python Solution ✔ Verified
n = int(input())
arr = [int(input()) for _ in range(n)]
t = int(input())
low, high, result = 0, n-1, -1
while low <= high:
mid = (low + high) // 2
if arr[mid] == t:
result = mid; break
elif arr[mid] < t:
low = mid + 1
else:
high = mid - 1
print(result)
Time: O(log n)Space: O(1)
48
MediumSorting
Find Kth Largest Element
Given an array of N integers and integer K, find the Kth largest element.
Input 1
[3,2,1,5,6,4], K=2
Output 1
5
Input 2
[3,2,3,1,2,4,5,5,6], K=4
Output 2
4
⚙ Approach Sort in descending order and return element at index K-1. Or use min-heap of size K for O(n log k).
Python Solution ✔ Verified
n = int(input())
arr = [int(input()) for _ in range(n)]
k = int(input())
arr.sort(reverse=True)
print(arr[k-1])
Time: O(n log n)Space: O(1)
49
MediumSorting
Merge Two Sorted Arrays
Given two sorted arrays of sizes M and N, merge them into a single sorted array.
Input 1
[1,3,5] [2,4,6]
Output 1
1 2 3 4 5 6
Input 2
[1,2] [3,4]
Output 2
1 2 3 4
⚙ Approach Two-pointer merge: compare front elements of both arrays, pick the smaller one.
Python Solution ✔ Verified
m = int(input())
a = [int(input()) for _ in range(m)]
n = int(input())
b = [int(input()) for _ in range(n)]
i = j = 0
res = []
while i < m and j < n:
if a[i] <= b[j]:
res.append(a[i]); i += 1
else:
res.append(b[j]); j += 1
res.extend(a[i:])
res.extend(b[j:])
print(*res)
Time: O(m+n)Space: O(m+n)
50
MediumSorting
Check if Array Can Be Sorted by Adjacent Swaps (Bubble Sort Passes)
Given an array, determine the minimum number of bubble sort passes needed to fully sort it. Print the count.
Input 1
[1,2,3,4,5]
Output 1
0
Input 2
[5,4,3,2,1]
Output 2
4
Input 3
[1,3,2,4]
Output 3
1
⚙ Approach Simulate bubble sort counting passes. A pass that makes no swaps is the first unnecessary pass.
Python Solution ✔ Verified
n = int(input())
arr = [int(input()) for _ in range(n)]
passes = 0
for i in range(n):
swapped = False
for j in range(0, n-i-1):
if arr[j] > arr[j+1]:
arr[j], arr[j+1] = arr[j+1], arr[j]
swapped = True
if swapped:
passes += 1
else:
break
print(passes)
Time: O(n^2)Space: O(1)
Section 6
⭐ Pattern Printing — Q51 to Q54
Pattern Printing
Pattern questions test nested loop understanding and appear occasionally in TCS Foundation section.
51
EasyPatterns
Right-Angled Triangle of Stars
Print a right-angled triangle pattern of stars with N rows. Row i has i stars.
Input 1
5
Output 1
*
**
***
****
*****
⚙ Approach For each row i from 1 to N, print i stars.
Python Solution ✔ Verified
n = int(input())
for i in range(1, n+1):
print("*" * i)
Time: O(n^2)Space: O(1)
52
EasyPatterns
Number Pyramid Pattern
Print a number pyramid with N rows. Row i contains numbers 1 to i separated by spaces.
Input 1
4
Output 1
1
1 2
1 2 3
1 2 3 4
⚙ Approach For each row i, print numbers 1 to i.
Python Solution ✔ Verified
n = int(input())
for i in range(1, n+1):
print(*range(1, i+1))
Time: O(n^2)Space: O(1)
53
EasyPatterns
Inverted Star Triangle
Print an inverted right-angled triangle of stars with N rows starting from N stars down to 1.
Input 1
4
Output 1
****
***
**
*
⚙ Approach Loop from N down to 1 printing that many stars per row.
Python Solution ✔ Verified
n = int(input())
for i in range(n, 0, -1):
print("*" * i)
Time: O(n^2)Space: O(1)
54
MediumPatterns
Diamond Pattern
Print a diamond pattern of stars with N rows (N must be odd). The widest row (middle) has N stars.
Input 1
5
Output 1
*
***
*****
***
*
⚙ Approach Print upper half: rows with 1,3,...,N stars with padding. Then lower half: N-2,...,1 stars.
Python Solution ✔ Verified
n = int(input())
for i in range(1, n+1, 2):
print(" " * ((n-i)//2) + "*" * i)
for i in range(n-2, 0, -2):
print(" " * ((n-i)//2) + "*" * i)
Time: O(n^2)Space: O(1)
Section 7
🔄 Recursion & Dynamic Programming — Q55 to Q58
Recursion & Dynamic Programming
These appear in the Advanced coding section. Practise these if you are targeting TCS Digital or higher packages.
55
MediumRecursion
Tower of Hanoi
Given N disks and 3 rods (A, B, C), print all steps to move disks from A to C using B as auxiliary. Rules: only one disk at a time, no larger disk on smaller.
Input 1
2
Output 1
A->C, A->B, C->B
Input 2
3
Output 2
7 moves total
⚙ Approach Recursive: move N-1 disks to auxiliary, move Nth disk to destination, move N-1 from auxiliary to destination.
Python Solution ✔ Verified
def hanoi(n, src, dest, aux):
if n == 1:
print(f"{src}->{dest}")
return
hanoi(n-1, src, aux, dest)
print(f"{src}->{dest}")
hanoi(n-1, aux, dest, src)
n = int(input())
hanoi(n, "A", "C", "B")
Time: O(2^n)Space: O(n)
56
MediumDynamic Programming
Longest Common Subsequence (LCS)
Given two strings S1 and S2, find the length of their Longest Common Subsequence.
Input 1
ABCBDAB BDCABA
Output 1
4
Input 2
AGGTAB GXTXAYB
Output 2
4
⚙ Approach Classic DP: dp[i][j] = LCS length of S1[:i] and S2[:j]. Fill bottom-up. If chars match: dp[i][j] = dp[i-1][j-1]+1.
Python Solution ✔ Verified
s1 = input().strip()
s2 = input().strip()
m, n = len(s1), len(s2)
dp = [[0]*(n+1) for _ in range(m+1)]
for i in range(1, m+1):
for j in range(1, n+1):
if s1[i-1] == s2[j-1]:
dp[i][j] = dp[i-1][j-1] + 1
else:
dp[i][j] = max(dp[i-1][j], dp[i][j-1])
print(dp[m][n])
Time: O(m*n)Space: O(m*n)
57
MediumDynamic Programming
0/1 Knapsack Problem
Given N items each with weight W[i] and value V[i], and capacity C, find the maximum value that fits. Each item can be used at most once.
Input 1
W=[1,2,3] V=[6,10,12] C=5
Output 1
22
Input 2
W=[2,3,4,5] V=[3,4,5,6] C=5
Output 2
7
⚙ Approach Classic 0/1 knapsack DP. dp[i][w] = max value using first i items with capacity w. Include or exclude each item.
Python Solution ✔ Verified
n, c = int(input()), int(input())
w = list(map(int, input().split()))
v = list(map(int, input().split()))
dp = [[0]*(c+1) for _ in range(n+1)]
for i in range(1, n+1):
for cap in range(c+1):
dp[i][cap] = dp[i-1][cap]
if w[i-1] <= cap:
dp[i][cap] = max(dp[i][cap],
dp[i-1][cap-w[i-1]] + v[i-1])
print(dp[n][c])
Time: O(n*c)Space: O(n*c)
58
MediumRecursion
Count Subsets with Given Sum
Given an array of N non-negative integers and a target sum S, count the number of subsets that sum exactly to S.
Input 1
[1,2,3,4,5] S=5
Output 1
3
Input 2
[3,3,3] S=6
Output 2
3
⚙ Approach Recursive solution: at each element, either include it (subtract from S) or exclude it. Base cases: S==0 → 1 way, no elements → 0 ways.
Python Solution ✔ Verified
def count_subsets(arr, n, s):
if s == 0: return 1
if n == 0: return 0
if arr[n-1] > s:
return count_subsets(arr, n-1, s)
return (count_subsets(arr, n-1, s) +
count_subsets(arr, n-1, s - arr[n-1]))
n = int(input())
arr = list(map(int, input().split()))
s = int(input())
print(count_subsets(arr, n, s))
Time: O(2^n)Space: O(n)
Section 8
🎯 Miscellaneous — Q59 to Q60
Miscellaneous & Logic
These don't fit a neat category but have appeared in real TCS NQT exam slots.
59
EasyMiscellaneous
Caesar Cipher — Encrypt a String
Given a plaintext string and shift K, encrypt using Caesar cipher (shift each letter by K, wrap around). Preserve case and non-alphabetic characters.
Input 1
Hello K=3
Output 1
Khoor
Input 2
xyz K=3
Output 2
abc
⚙ Approach For each character: compute position, apply shift mod 26, convert back. Non-alpha characters stay unchanged.
Python Solution ✔ Verified
text = input()
k = int(input()) % 26
result = []
for c in text:
if c.isalpha():
base = ord('A') if c.isupper() else ord('a')
result.append(chr((ord(c) - base + k) % 26 + base))
else:
result.append(c)
print(''.join(result))
Time: O(n)Space: O(n)
60
EasyMiscellaneous
Leap Year Checker
Given a year Y, determine if it is a leap year. A year is a leap year if divisible by 4, except century years must be divisible by 400.
Input 1
2024
Output 1
Leap Year
Input 2
1900
Output 2
Not Leap Year
Input 3
2000
Output 3
Leap Year
⚙ Approach Rule: (divisible by 4 AND not divisible by 100) OR divisible by 400.
Python Solution ✔ Verified
y = int(input())
if (y % 4 == 0 and y % 100 != 0) or (y % 400 == 0):
print("Leap Year")
else:
print("Not Leap Year")
Time: O(1)Space: O(1)
FAQ
Frequently Asked Questions
How many coding questions are asked in TCS NQT? ▼
TCS NQT has 1–2 coding questions in 60–90 minutes. Foundation section: 1 easy-medium problem. Advanced section: 1 harder problem.
What programming languages are allowed in TCS NQT? ▼
Python, Java, C, and C++ are allowed. Python is recommended for faster and cleaner solutions.
Medium difficulty. Story-based problems test logical thinking, not advanced DSA. Knowing arrays, strings, and basic math in Python is sufficient to attempt both questions.
Is there negative marking in TCS NQT coding? ▼
There is no negative marking in the coding section. Partial marks may be awarded based on test cases passed. Always attempt to submit even if your solution is not perfect.
What is TITA in TCS NQT coding? ▼
TITA stands for Type In The Answer. Your code output must exactly match the expected output including spaces and newlines. Always use print() carefully in Python.
Courses
Want Complete TCS NQT Preparation?
Explore all CampusMonk courses — mock tests, recorded programs, and full placement packs.
Cognizant runs three entry-level hiring tracks — GenC (4 LPA), GenC Pro (5.4 LPA), and GenC Next (6.75 LPA). Each has a slightly different assessment focus, but the core Online Assessment has the same structure. Here's the full breakdown so you're not surprised on exam day.
60
Communication Round
Reading, Grammar, Repeat-sentences via mic. Elimination round. Duration: 60 minutes.
3 coding or technical tasks based on your chosen skill cluster (Java/SQL/Python). Duration: 105–120 mins.
1:1
Interview Round
Technical + HR in one interview. GenC Next interviews last ~1 hour and go deep on DSA + DBMS.
💡 No negative marking — attempt every question. The platform is the Safe Assessment Browser (SAB). Tab switching is tracked. Practice on similar timed platforms before your actual exam.
📐
Section 1: Quantitative Aptitude
Q1 – Q20
1
There are 40 students in a class — 14 taking Maths and 29 taking Computer. What is the probability that a randomly chosen student is taking only the Computer class?
▾
A) 40%
B) 55%
C) 65%
D) 70%
✅ Answer: C) 65%
Students taking both = 14 + 29 − 40 = 3. Only Computer = 29 − 3 = 26. Probability = 26/40 = 65%.
2
Three cubes of edges 6 cm, 8 cm and 10 cm are melted without loss of metal into a single cube. What is the edge of the new cube?
If all 6s get inverted and become 9s between 1 and 100 (inclusive), by how much will the sum of all numbers change?
▾
A) 300
B) 330
C) 333
D) None of these
✅ Answer: B) 330
6 at unit place (6, 16, 26… 96) → 10 numbers → increase by 3 each = +30. 6 at tens place (60–69) → 10 numbers → increase by 30 each = +300. Total = 330.
4
Rajesh spent money on 5 pens, 3 notebooks & 9 pencils. Prabhu bought 6 pens, 6 notebooks & 18 pencils and paid 50% more than Rajesh. What % of Rajesh's money was spent on pens?
▾
A) 62.5%
B) 12.5%
C) 75%
D) Cannot be determined
✅ Answer: A) 62.5%
Let Rajesh spend x. Solving the equations: 1 pen = 0.125x. So 5 pens = 0.625x = 62.5%.
5
A person walks at 10 km/h to reach a destination. He walks back the same route at 14 km/h arriving 20 km less. What was the actual distance?
▾
A) 50 km
B) 40 km
C) 60 km
D) 45 km
✅ Answer: A) 50 km
Let x = distance. x/10 = (x+20)/14 → 14x = 10x + 200 → 4x = 200 → x = 50 km.
6
A bus covers 54 km/h without stoppages and 45 km/h with stoppages. For how many minutes per hour does the bus stop?
▾
A) 10
B) 12
C) 20
D) 9
✅ Answer: A) 10 minutes
Distance lost per hour = 54 − 45 = 9 km. Time to cover 9 km at 54 km/h = (9/54) × 60 = 10 minutes.
7
The distance between cities P and Q is 300 km. Train from P starts at 10 AM at 80 km/h; train from Q starts at 11 AM at 40 km/h. At what time do they meet?
▾
A) 12:50 PM
B) 1:00 PM
C) 12:20 PM
D) 12:40 PM
✅ Answer: A) 12:50 PM
By 11 AM, Train P covers 80 km. Remaining = 220 km. Closing speed = 120 km/h. Time = 220/120 = 1 hr 50 min. 11:00 + 1:50 = 12:50 PM.
8
A shopkeeper bought 30 kg rice at ₹40/kg. Sold 40% at ₹50/kg. At what price per kg should he sell the rest to make a 25% overall profit?
▾
A) ₹50
B) ₹40
C) ₹30
D) ₹54
✅ Answer: A) ₹50
Total CP = 30×40 = ₹1200. Required SP = 1200 × 1.25 = ₹1500. SP of first 12 kg = ₹600. Remaining SP needed = ₹900 for 18 kg = ₹50/kg.
9
The greatest number that divides 964, 1238, and 1400 leaving remainders 41, 31, and 51 respectively is?
Average price of 10 books is ₹12. Average price of 8 of those books is ₹11.75. Of the remaining 2 books, one is 60% more than the other. Find the price of each.
▾
A) ₹12 & ₹24
B) ₹24 & ₹18
C) ₹28 & ₹12
D) ₹10 & ₹16
✅ Answer: D) ₹10 & ₹16
Sum of 2 books = 120 − 94 = ₹26. Let cheaper = x, pricier = 1.6x. x + 1.6x = 26 → x = ₹10, other = ₹16.
13
Two trucks face each other 500 cm apart. Each moves forward 100 cm at 50 cm/s, then backward 50 cm at 25 cm/s. How long until they collide?
▾
A) 12 sec
B) 16 sec
C) 13 sec
D) 14 sec
✅ Answer: D) 14 seconds
Each cycle (2s forward + 2s back) each truck nets +50 cm. At 14 sec, each truck has moved 250 cm → total 500 cm → collision.
14
A secret can be told by 2 persons in 5 minutes. Each tells it to 2 more, and so on. How long will it take to reach 768 persons?
▾
A) 500 min
B) 50 min
C) 47.5 min
D) 49 min
✅ Answer: C) 47.5 minutes
Series: 1, 2, 4, 8, …, 512. Up to 512 people = 45 min. Then 256 people tell 256 more → +2.5 min. Total = 47.5 min.
15
378 coins consist of ₹1, 50p and 25p coins whose values are in ratio 13:11:7. How many 50p coins are there?
▾
A) 132
B) 154
C) 176
D) 132
✅ Answer: B) 154
Value ratio 13:11:7 → coin count ratio = 13:22:28 (divide by denomination). Total = 63 parts = 378 → 1 part = 6. 50p coins = 22×6 = 132. (Verify with your actual exam version as ratios vary.)
16
In a group, 6 speak Tamil, 15 speak Hindi, 6 speak Gujarati. 2 speak two languages, 1 speaks all three. How many people are in the group?
▾
A) 21
B) 22
C) 24
D) 23
✅ Answer: D) 23
Only Tamil = 3, Only Hindi = 12, Only Gujarati = 5. Total = 20 + 2 (bilingual) + 1 (trilingual) = 23.
17
A and B can complete a work in 12 days together. B and C in 15 days, A and C in 20 days. How many days will A alone take?
▾
A) 30 days
B) 20 days
C) 24 days
D) 40 days
✅ Answer: A) 30 days
2(A+B+C) = 1/12+1/15+1/20 = 1/5. So A+B+C = 1/10. A alone = 1/10 − 1/15 = 1/30 → 30 days.
18
A train 150 m long passes a telegraph pole in 15 seconds. How long will it take to pass a platform 300 m long?
▾
A) 30 sec
B) 45 sec
C) 40 sec
D) 60 sec
✅ Answer: B) 45 seconds
Speed = 150/15 = 10 m/s. Distance to cross platform = 150+300 = 450 m. Time = 450/10 = 45 seconds.
19
Simple interest on a sum at 5% per annum for 3 years is ₹1200. What is the compound interest on the same sum at the same rate for 2 years?
▾
A) ₹800
B) ₹820
C) ₹840
D) ₹860
✅ Answer: B) ₹820
SI = PRT/100 → 1200 = P×5×3/100 → P = ₹8000. CI for 2 years = 8000×[(1.05)²−1] = 8000×0.1025 = ₹820.
20
In how many ways can 5 men and 3 women be arranged in a row so that no two women sit together?
▾
A) 1440
B) 14400
C) 720
D) 2880
✅ Answer: B) 14400
Arrange 5 men: 5! = 120. Women can sit in 6 gaps (between/outside men): ⁶P₃ = 120. Total = 120 × 120 = 14400.
🧠
Section 2: Logical Reasoning
Q21 – Q40
21
There are 6 cities, every city connected to each other. How many different routes from A to B such that no city is touched more than once?
▾
A) 72
B) 65
C) 60
D) 48
✅ Answer: B) 65
Direct = 1. Via 1 city = 4. Via 2 = 4×3=12. Via 3 = 24. Via 4 = 24. Total = 1+4+12+24+24 = 65.
22
Find the next number in the series: 2, 6, 12, 20, 30, ?
Which number does not belong in the group: 16, 25, 36, 72, 144, 196?
▾
A) 36
B) 72
C) 144
D) 196
✅ Answer: B) 72
All others are perfect squares (4², 5², 6², 12², 14²). 72 is not a perfect square.
38
A is B's sister. C is B's mother. D is C's father. E is D's mother. How is A related to D?
▾
A) Daughter
B) Grand Daughter
C) Great-granddaughter
D) Mother
✅ Answer: B) Grand Daughter
A is B's sister → A and B are children of C. C is D's daughter. So A is D's Grand Daughter.
39
Deductive reasoning game (Geo-Sudo type): In a 3×3 grid, each row and column must contain 1–3 without repetition. If row 1 is [1, _, 3] and column 2 has 3 in row 2, what is row 1 missing number?
▾
A) 2
B) 1
C) 3
D) Cannot determine
✅ Answer: A) 2
Row 1 has 1 and 3. The missing number must be 2 (each number 1–3 appears once per row).
40
What is the angle between the hour and minute hands at 3:15?
▾
A) 0°
B) 7.5°
C) 15°
D) 22.5°
✅ Answer: B) 7.5°
At 3:15, minute hand = 90°. Hour hand = 90 + (15×0.5) = 97.5°. Difference = 7.5°.
📖
Section 3: Verbal Ability
Q41 – Q55
41
Choose the correct sentence: A) She don't know the answer. B) She doesn't knows the answer. C) She doesn't know the answer. D) She not know the answer.
▾
A) Sentence A
B) Sentence B
C) Sentence C
D) Sentence D
✅ Answer: C
"She doesn't know the answer" uses correct subject-verb agreement with third-person singular.
42
Fill in the blank: The committee ______ yet to reach a decision. (has / have)
▾
A) has
B) have
C) are
D) were
✅ Answer: A) has
"Committee" is a collective noun treated as singular in formal English → has.
Verbose means using more words than needed. Wordy is the closest synonym.
45
Spot the error: "The team are playing good in the tournament."
▾
A) team are
B) No error
C) playing good
D) in the
✅ Answer: C) playing good
Should be "playing well" — "well" is the adverb modifying the verb "playing", not the adjective "good".
46
Choose the word closest in meaning to EPHEMERAL:
▾
A) Eternal
B) Transient
C) Permanent
D) Stable
✅ Answer: B) Transient
Ephemeral = lasting for a very short time. Transient has the same meaning.
47
Fill in: Neither the manager nor the employees ______ present for the meeting.
▾
A) was
B) were
C) is
D) has been
✅ Answer: B) were
With "neither…nor", the verb agrees with the subject closer to it (employees = plural) → were.
48
One word substitution: A person who cannot be corrected.
▾
A) Inexplicable
B) Invincible
C) Incorrigible
D) Inexorable
✅ Answer: C) Incorrigible
Incorrigible means a person who cannot be reformed or corrected.
49
Rearrange: TRAMS / SMART / RAMPS — which is NOT an anagram of the others?
▾
A) TRAMS
B) SMART
C) RAMPS
D) All are anagrams
✅ Answer: C) RAMPS
TRAMS and SMART both use T,R,A,M,S. RAMPS uses R,A,M,P,S — different letter (P instead of T) → not an anagram.
50
Choose the correct passive voice: "The manager approved the project."
▾
A) The project was approved by the manager.
B) The project is approved by the manager.
C) The project had been approved the manager.
D) The project approved by the manager.
✅ Answer: A
Simple past active → past passive = "was + past participle by subject" → The project was approved by the manager.
51
Reading comprehension (common type): If the passage says "Technology is a double-edged sword," the author most likely means:
▾
A) Technology is dangerous
B) Technology is beneficial
C) Technology has both benefits and drawbacks
D) Technology is neutral
✅ Answer: C
"Double-edged sword" is an idiom meaning something has both positive and negative effects simultaneously.
52
Which sentence uses the correct tense? "By the time she arrives, we ______ the project."
▾
A) finish
B) finished
C) will have finished
D) were finishing
✅ Answer: C) will have finished
"By the time" with a future reference requires the future perfect tense.
53
Choose the correctly spelled word:
▾
A) Accomodate
B) Acommodate
C) Accommodate
D) Accomadate
✅ Answer: C) Accommodate
Accommodate has double 'c' and double 'm' — a commonly misspelled word in Cognizant verbal tests.
54
Sentence completion: The new software was ______ by the team after weeks of testing. (A) inaugurated (B) demolished (C) deployed (D) confiscated
▾
A) Inaugurated
B) Demolished
C) Deployed
D) Confiscated
✅ Answer: C) Deployed
In a tech context, software is deployed — released for use. This is common Cognizant verbal context.
55
Identify the type of error: "He is one of those employees who works late every night."
▾
A) No error
B) Tense error
C) Subject-verb agreement error
D) Article error
✅ Answer: C
"One of those employees who" requires plural verb → should be "work late every night" because the relative clause refers to "employees" (plural).
💻
Section 4: Technical / CS Fundamentals
Q56 – Q75
56
What is the time complexity of Binary Search?
▾
A) O(n)
B) O(log n)
C) O(n²)
D) O(1)
✅ Answer: B) O(log n)
Binary search halves the search space each iteration → O(log n) time complexity.
57
Which OOP concept is illustrated when a child class inherits methods from a parent class?
▾
A) Encapsulation
B) Polymorphism
C) Inheritance
D) Abstraction
✅ Answer: C) Inheritance
Inheritance allows a class to reuse attributes and methods from another class, forming a parent-child relationship.
58
What does SDLC stand for, and what is its purpose?
▾
A) Software Design Life Cycle — to design software
B) Software Development Life Cycle — systematic process for building software
C) System Deployment Life Cycle — deploying systems
D) Software Debug Life Cycle — fixing bugs
✅ Answer: B
SDLC (Software Development Life Cycle) is the structured process of planning, building, testing, and maintaining software. Phases: Requirement → Design → Implement → Test → Deploy → Maintain.
59
Why is Java considered more secure than C/C++?
▾
A) Java uses pointers
B) Java has no explicit pointer manipulation and runs in JVM sandbox
C) Java is slower
D) Java doesn't use memory
✅ Answer: B
Java eliminates direct memory access via pointers. Programs run in the JVM sandbox, preventing direct OS-level attacks and buffer overflow exploits common in C/C++.
60
What is the output of: print(type([])) in Python?
▾
A) <class 'tuple'>
B) <class 'list'>
C) <class 'dict'>
D) <class 'set'>
✅ Answer: B) <class 'list'>
[] is an empty list literal in Python. type([]) returns <class 'list'>.
61
Which data structure uses LIFO (Last In, First Out) principle?
▾
A) Queue
B) Stack
C) Linked List
D) Tree
✅ Answer: B) Stack
A Stack follows LIFO — the last element added is the first one removed. Like a stack of plates.
62
What is polymorphism in OOP?
▾
A) Hiding data from outside world
B) Inheriting from multiple classes
C) One interface, multiple implementations
D) Storing different data types
✅ Answer: C
Polymorphism means "many forms." The same method name can behave differently depending on the object. Example: method overloading and overriding.
63
What is the difference between a process and a thread?
▾
A) No difference
B) A process has its own memory; threads share process memory
C) A thread is heavier than a process
D) Threads run on different CPUs only
✅ Answer: B
A process = independent program with its own memory. A thread = lightweight unit within a process that shares the same memory space.
64
What does the 'final' keyword mean in Java?
▾
A) The class runs faster
B) Variable/method/class cannot be modified or overridden
C) Method is static
D) It initializes automatically
✅ Answer: B
In Java, final variable = constant, final method = can't be overridden, final class = can't be inherited.
65
What is a primary key in a database?
▾
A) Any column in a table
B) A column (or set of columns) that uniquely identifies each row
C) A foreign key reference
D) An indexed column only
✅ Answer: B
A primary key uniquely identifies each record in a table. It cannot be NULL and must be unique for every row.
66
What is the worst-case time complexity of QuickSort?
▾
A) O(n log n)
B) O(n²)
C) O(n)
D) O(log n)
✅ Answer: B) O(n²)
QuickSort's worst case is O(n²) when the pivot is always the smallest or largest element (e.g., sorted array with bad pivot choice). Average = O(n log n).
67
What is the output of this Java snippet? int x = 5; System.out.println(x++); System.out.println(x);
▾
A) 6 and 6
B) 5 and 6
C) 5 and 5
D) 6 and 5
✅ Answer: B) 5 and 6
x++ is post-increment → prints current value (5) first, then increments. Next print shows 6.
68
Which HTTP method is used to update data on a server (partial update)?
▾
A) GET
B) POST
C) PUT
D) PATCH
✅ Answer: D) PATCH
PATCH is for partial updates. PUT replaces the entire resource. POST creates new. GET retrieves.
69
In an array of size n, what is the time complexity of accessing element at index i?
▾
A) O(1)
B) O(n)
C) O(log n)
D) O(n²)
✅ Answer: A) O(1)
Array elements are stored at contiguous memory locations. Access by index is direct → O(1) constant time.
70
What is encapsulation in OOP?
▾
A) Bundling data and methods together, hiding internal details
B) Creating multiple child classes
C) Writing the same method with different parameters
D) Running code in parallel
✅ Answer: A
Encapsulation wraps data (variables) and methods inside a class and controls access using access modifiers (private, public, protected).
71
What is a deadlock in operating systems?
▾
A) A process running too fast
B) Two or more processes waiting for each other's resources indefinitely
C) An infinite loop in code
D) Memory overflow
✅ Answer: B
A deadlock occurs when processes are stuck in a circular wait — each holds a resource the other needs, so none can proceed.
72
What is the purpose of the 'static' keyword in Java?
▾
A) It makes a variable final
B) It belongs to the class, not to an instance
C) It prevents inheritance
D) It automatically initializes variables
✅ Answer: B
static means the variable or method belongs to the class itself, not to any particular object. All instances share the same static member.
73
What does HTML stand for?
▾
A) Hyper Text Making Language
B) HyperText Markup Language
C) High Transfer Markup Language
D) Hyper Transfer Markup Language
✅ Answer: B) HyperText Markup Language
HTML is the standard language for creating web pages. It uses tags to structure content for display in browsers.
74
What is normalization in database design?
▾
A) Organizing tables to reduce data redundancy and improve integrity
B) Speeding up queries with indexes
C) Encrypting the database
D) Backing up the database
✅ Answer: A
Normalization is the process of organizing database tables to minimize redundancy. Forms: 1NF, 2NF, 3NF, BCNF.
75
What is the difference between == and .equals() in Java?
▾
A) == compares references; .equals() compares actual content/values
B) They are exactly the same
C) == compares values; .equals() compares memory
D) .equals() only works for integers
✅ Answer: A
== checks if two variables point to the same object in memory. .equals() checks if the content of two objects is the same.
⌨️
Section 5: Coding Problems (GenC Next)
Q76 – Q85
76
Write a function to check if a string is a palindrome. What is the most efficient approach?
▾
A) Use nested loops O(n²)
B) Use two-pointer technique O(n)
C) Reverse and compare using recursion O(n log n)
D) Sort and compare O(n log n)
✅ Answer: B) Two-pointer O(n)
Compare characters from both ends moving inward. If any mismatch → not a palindrome.
defis_palindrome(s):
left, right = 0, len(s) - 1while left < right:
if s[left] != s[right]:
returnFalse
left += 1
right -= 1returnTrue
77
There are N suns in a galaxy, each with M planets, each with some moons [galaxy[i][j]]. Find the maximum number of moons in any single solar system.
▾
A) Sum each row, return maximum row sum
B) Find the maximum single cell value
C) Sum all values in the entire grid
D) Count number of columns
✅ Answer: A — Sum rows, find maximum
Each solar system (row) = one sun. Sum all moons per sun, return the highest total.
Find the second largest element in an unsorted array without sorting it. What is the time complexity?
▾
A) O(n log n) — sort then pick
B) O(n) — single pass tracking two variables
C) O(n²) — nested loops
D) O(1) — direct access
✅ Answer: B) O(n)
Track first and second max in one pass.
defsecond_largest(arr):
first = second = float('-inf')
for n in arr:
if n > first:
second = first
first = n
elif n > second and n != first:
second = n
return second
79
Reverse a linked list. Which approach uses O(1) extra space?
▾
A) Store in array then rebuild
B) Iterative three-pointer technique
C) Recursive approach
D) Sort the linked list
✅ Answer: B) Iterative — O(1) space
Use prev, curr, next pointers. No extra memory needed.
What does this code output? x = [1, 2, 3]; y = x; y.append(4); print(x)
▾
A) [1, 2, 3]
B) [1, 2, 3, 4]
C) Error
D) [4, 1, 2, 3]
✅ Answer: B) [1, 2, 3, 4]
y = x does NOT copy the list — both y and x point to the same list object. Modifying y also modifies x. This is Python's reference semantics.
84
Find if a number is prime. What is the most efficient method up to √n?
▾
A) Check divisibility up to n — O(n)
B) Check divisibility up to √n — O(√n)
C) Sieve of Eratosthenes for one number
D) Use modulo of n/2
✅ Answer: B) O(√n)
import math
defis_prime(n):
if n < 2: returnFalsefor i inrange(2, int(math.sqrt(n)) + 1):
if n % i == 0: returnFalsereturnTrue
85
Given a string, find the first non-repeating character. E.g., "swiss" → 'w'
▾
A) Build frequency map then scan in order — O(n)
B) Nested loops to check each char — O(n²)
C) Sort the string — O(n log n)
D) Use recursion
✅ Answer: A) O(n)
from collections import Counter
deffirst_unique(s):
freq = Counter(s)
for ch in s:
if freq[ch] == 1:
return ch
returnNone
🗄️
Section 6: SQL & DBMS
Q86 – Q93
86
What is the difference between WHERE and HAVING in SQL?
▾
A) No difference
B) WHERE filters rows before grouping; HAVING filters groups after GROUP BY
C) HAVING is faster than WHERE
D) WHERE works only on strings
✅ Answer: B
WHERE filters individual rows before any grouping. HAVING filters after GROUP BY — used with aggregate functions like COUNT, SUM, AVG.
87
Write a query to find employees who earn more than the average salary.
▾
A) SELECT * FROM employees WHERE salary > (SELECT AVG(salary) FROM employees);
B) SELECT * FROM employees HAVING salary > AVG(salary);
C) SELECT AVG(salary) FROM employees WHERE salary > 0;
D) SELECT * FROM employees ORDER BY salary DESC;
✅ Answer: A
SELECT * FROM employees
WHERE salary > (SELECTAVG(salary) FROM employees);
88
What is the difference between INNER JOIN and LEFT JOIN?
▾
A) INNER JOIN returns only matching rows; LEFT JOIN returns all rows from left table even without a match
B) They are the same
C) LEFT JOIN is faster
D) INNER JOIN returns all rows from both tables
✅ Answer: A
INNER JOIN = only rows where condition matches in BOTH tables. LEFT JOIN = all rows from left table + matched rows from right (NULLs for no match).
89
What is a foreign key?
▾
A) Key from another database
B) A column that references the primary key of another table
C) An alternate primary key
D) A key that allows NULL values only
✅ Answer: B
A foreign key establishes a relationship between two tables. It references the primary key of another table to maintain referential integrity.
90
Write a query to find the second highest salary from an Employee table.
▾
A) SELECT MAX(salary) FROM employees WHERE salary < (SELECT MAX(salary) FROM employees);
B) SELECT salary FROM employees ORDER BY salary DESC LIMIT 1;
C) SELECT MIN(salary) FROM employees;
D) SELECT salary FROM employees GROUP BY salary;
✅ Answer: A
SELECTMAX(salary) FROM employees
WHERE salary < (SELECTMAX(salary) FROM employees);
91
What does the GROUP BY clause do in SQL?
▾
A) Sorts the results
B) Groups rows with the same values into summary rows for aggregate functions
C) Filters duplicate rows
D) Joins multiple tables
✅ Answer: B
GROUP BY groups rows sharing a value so aggregate functions (COUNT, SUM, AVG) can be applied per group. Example: count employees per department.
92
What is the difference between DELETE, DROP, and TRUNCATE in SQL?
▾
A) DELETE removes rows (can rollback); TRUNCATE removes all rows (faster, no rollback); DROP removes the entire table
B) They are all the same
C) DROP is reversible, DELETE is not
D) TRUNCATE removes the table structure
✅ Answer: A
DELETE: removes specific rows, logged, can be rolled back. TRUNCATE: removes all rows instantly, not easily rolled back. DROP: removes the entire table including its structure.
93
What is an index in a database and why is it used?
▾
A) It sorts data alphabetically
B) It speeds up data retrieval by creating a lookup structure
C) It encrypts the table
D) It is used to join tables
✅ Answer: B
A database index is like a book's table of contents — it allows the database engine to find rows quickly without scanning the entire table. It speeds up SELECT queries but slightly slows INSERT/UPDATE.
🤝
Section 7: HR Interview Questions
Q94 – Q100
94
Tell me about yourself. What should you focus on?
▾
A) Your entire life story
B) Your family background
C) Education → Skills → Projects → Why Cognizant
D) Your hobbies only
✅ Best Approach
Structure: Name + degree + college → key technical skills → most relevant project → why you want to work at Cognizant. Keep it to 90 seconds. End with enthusiasm about the role.
95
Why do you want to work at Cognizant?
▾
A) "Because it pays well"
B) Mention Cognizant's work culture, learning opportunities, digital transformation projects
C) "I applied everywhere"
D) "It's close to my home"
✅ Best Approach
Talk about Cognizant's focus on digital transformation, cloud, AI, and their global presence. Mention how their GenC/GenC Next training programs align with your goal of building a strong technical foundation early in your career.
96
What is your greatest weakness?
▾
A) "I have no weaknesses"
B) "I work too hard"
C) Name a real weakness + what you're doing to improve it
D) "I hate working in teams"
✅ Best Approach
Be honest but strategic. Example: "I sometimes struggle with public speaking, but I've been joining group discussions and tech meetups to practice. I've noticed a visible improvement in the last few months." Shows self-awareness + initiative.
97
Where do you see yourself in 5 years?
▾
A) "Running my own company"
B) "In your position"
C) "Growing into a technical lead role within Cognizant, specializing in cloud/AI"
D) "Retired"
✅ Best Approach
Show ambition but tie it to Cognizant's growth. Example: "I want to develop expertise in cloud solutions and eventually contribute as a solution architect. I see Cognizant as the perfect place to grow because of your training programs and global projects."
98
Describe a situation where you worked in a team to solve a problem. (STAR method)
▾
A) Make up a story
B) Say you always work alone
C) Use Situation → Task → Action → Result format with a real example
D) Keep it vague
✅ Best Approach
Use the STAR method: Situation (project context) → Task (your role) → Action (what you did specifically) → Result (measurable outcome). Example: College project where your team was stuck on a bug and you led the debugging session, reducing submission delay from 2 days to 6 hours.
99
Are you comfortable relocating?
▾
A) "Yes, I am open to relocation" (if true)
B) Refuse without explanation
C) Negotiate aggressively
D) Ask them to confirm your city first
✅ Best Approach
Cognizant often posts across multiple cities. If you're open to relocation, say so clearly and positively: "Yes, I'm open to working wherever the opportunity is. I believe exposure to different work environments will help me grow faster."
100
Do you have any questions for us? (End of interview)
▾
A) "No, I'm good"
B) Ask about salary immediately
C) Ask about the team, training program, or a recent Cognizant project
D) Ask when you'll get the offer letter
✅ Best Approach
Always have 1–2 thoughtful questions ready. Examples: "What does the typical learning curve look like for a GenC associate in the first 6 months?" or "What technologies does the team I'd be joining primarily work with?" This shows genuine interest and preparation.
🎯 Ready to Crack the Cognizant OA?
You've just gone through 100 real questions. Now it's time to practice under timed conditions. Accuracy + Speed = Selection.
Exact questions asked in TCS Digital and Prime role interviews, actual student experiences, and everything you need to walk in confident.
CampusMonkDigital & Prime Roles10 min read
"Sir, what happens in the TCS interview?" — This is the most common question every student asks after clearing TCS NQT. This blog gives you the real answers — from students who actually sat in the interview room in 2026.
You cleared the TCS NQT. Now comes the interview.
This is where most students get confused. They don't know what to expect. They prepare the wrong things. They get nervous for no reason.
The truth is — the TCS interview is very structured. Once you know what they ask, it becomes much less scary.
This blog covers everything — TCS HR Round questions, TCS Technical Round topics, and TCS Managerial Round — with real questions from actual 2026 TCS interviews for Digital and Prime roles.
Interview Structure
TCS Interview Structure 2026
Before we go into each round, understand this simple structure. TCS campus interviews have 3 rounds — all on the same day:
👩💼
Round 1
HR Round
Personality & fit check
💻
Round 2
Technical Round
Projects, SQL, coding
🤝
Round 3
Managerial Round
Attitude & flexibility
The good news? Most students who cleared TCS NQT also clear the interview — because TCS is looking for attitude and willingness to learn, not perfection.
HR Round
Round 1 — TCS HR Round Questions (with Answers)
The HR round is a simple 15–20 minute conversation. They are checking if you are genuine, confident, and a good fit for TCS culture.
Here are the most common TCS HR interview questions with tips on how to answer each:
HR Round Questions Asked in TCS 2026
Tell me about yourself — Prepare a 90-second answer: name, college, branch, key skills, one project, and why TCS.
Why did you choose this college? — Be honest. Keep it short and positive.
What do you know about TCS? — Mention TCS's size (largest IT company in India), its digital transformation work, global presence in 50+ countries, and its focus on fresher hiring.
Why do you want to join TCS? — Don't say "big company." Say: learning opportunities, global exposure, strong training program for freshers.
What are your strengths and weaknesses? — Give a real weakness. Always say how you are working to improve it.
What are your hobbies and interests? — Be genuine. If you say "coding," be ready to talk about it.
Why should we hire you? — Combine your skills, your attitude to learn, and your enthusiasm. Keep it to 60 seconds.
Pro Tip for HR Round: The biggest mistake students make is memorising answers word by word. The interviewer can tell. Instead, understand what each answer should communicate — then speak naturally. Practise out loud, not on paper.
Technical Round
Round 2 — TCS Technical Round Questions
This is the round students fear most. But here is the truth — TCS technical interviews mostly stay close to your resume and projects. They rarely go into deep DSA or system design for freshers.
Technical Topics Asked in TCS Digital & Prime 2026
Your Project Deep Dive — What did you build? What technology? How does the backend work? What problems did you face?
Networking Questions — API Gateway, IP Address, how a browser connects to a server (DNS → TCP → HTTP)
Spring Boot Concepts — For Java students: annotations, REST API, auto-configuration basics
SQL Queries — Joins, Subquery, Indexing, EXISTS, NOT EXISTS, IN, NOT IN, GROUP BY, HAVING
SQL Set Operations — Union, Union All, Intersect, Minus — know the differences
Basic Coding Problem — "Write a code to return the second maximum element"
Cloud Computing Basics — What is cloud? Public vs Private vs Hybrid. Basic understanding is enough.
SQL Topics You Must Revise Before TCS Technical Interview
SQL is asked in almost every TCS technical interview. These are the exact topics that come up most frequently:
SQL Topic
What to Know
Difficulty
Joins
INNER, LEFT, RIGHT, FULL OUTER — know with examples
Must Know
Subquery
Nested SELECT, correlated subquery
Must Know
Indexing
Why index speeds up queries, clustered vs non-clustered
Must Know
EXISTS / NOT EXISTS
Difference from IN / NOT IN, when to use which
Important
GROUP BY / HAVING
Difference between WHERE and HAVING
Must Know
Union vs Union All
Union removes duplicates, Union All keeps them
Important
Intersect / Minus
Common rows vs difference between result sets
Good to Know
Managerial Round
Round 3 — TCS Managerial Round Questions
Managerial Questions in TCS 2026
The most relaxed round. They are checking attitude, flexibility, and if you will fit into TCS work culture.
How many family members do you have?
Are you vegetarian or non-vegetarian? — No right answer. Just be honest.
Any location preferences? — "No preference" is the safest and best answer.
What are your strengths and weaknesses?
What are your hobbies and interests?
Why should we hire you? — Your final chance to make an impression.
The Managerial round rarely eliminates candidates. Think of it as a final check. Be relaxed, be natural, be honest.
Real Experience
Real TCS Interview Experience — A Student's Story
One of our CampusMonk students shared exactly what happened in their TCS Technical Round in 2026. This is one of the most valuable things you can read before your interview.
Technical Round — Actual Questions Asked (Student's Own Words)
1Interviewer asked: "Do you know about Cloud Computing?" — Student replied: "I know the basics but not in-depth." Interviewer said "OK" and moved on. Don't lie. Honesty works.
2Asked Networking questions — API Gateway, IP address, how browser connects with the server.
3Spring Boot related questions asked (student had Java in their resume).
4Asked to connect project with backend code. Student said MySQL not implemented yet — interviewer said "OK" and continued. Partial knowledge is fine. Don't freeze.
5"Write a code to return the second maximum element." Student wrote it correctly with just one small semicolon syntax error — still cleared the round.
6Personal question: "Why not defence exams since your father is in the army?" — Student said: "My passion is in IT." Short, honest, confident answer.
What this experience teaches us: TCS interviewers are not trying to fail you. They want to see how you think under pressure, how honest you are, and whether you can communicate clearly. You don't need to know everything — just know what you've put on your resume, be genuine, and stay calm.
Free Video
Watch This Free Video Before Your TCS Interview
This free YouTube session covers real TCS interview questions from Digital and Prime roles in 2026 — HR Round, Technical Round, and Managerial Round in one complete video.
CampusMonk — Free YouTube Session
TCS Interview Questions | Prime & Digital Actual Experience + Real Questions 2026
Real questions. Real answers. Real student experiences. HR + Technical + Managerial Round — all in one video. Completely free.
These are not generic tips. These come from students who sat in real TCS interviews and the questions they got wrong — or right.
Tip 01
Be honest about what you don't know. Saying "I'm not sure, but I'd approach it this way" is far better than guessing wrong.
Tip 02
Know your project inside out. Every technology on your resume is a potential question. If you put Java, be ready to write Java code.
Tip 03
Practise speaking out loud. Preparing silently is not enough. Record yourself answering, then listen back critically.
Tip 04
Dress formally and arrive 15 minutes early. First impressions shape the entire interview, especially in HR round.
Tip 05
Show your thinking, not just your answer. If stuck on coding, say what you're thinking. Interviewers value problem-solving approach.
Tip 06
Revise SQL the night before. Joins, Subqueries, Indexing — these come up in almost every TCS technical interview.
Tip 07
Prepare 2 questions to ask the interviewer. "What does a typical day look like for a fresher?" shows genuine interest.
Tip 08
Stay calm in Managerial round. It's mostly a conversation. Relax. Be yourself. There are no wrong answers about your family or food preferences.
FAQ
Frequently Asked Questions — TCS Interview 2026
These are the questions that students ask most about the TCS interview process. The FAQ schema on this page means Google may show these answers directly in search results.
How many rounds are there in TCS interview? ▼
TCS interview has 3 rounds — HR Round, Technical Round, and Managerial Round. All three rounds typically happen on the same day. Most students who clear TCS NQT also clear the interview.
What questions are asked in TCS HR Round? ▼
Common TCS HR round questions include: Tell me about yourself, Why do you want to join TCS, What do you know about TCS, What are your strengths and weaknesses, Why should we hire you, and questions about hobbies and interests.
What SQL topics come in TCS Technical Interview? ▼
TCS technical interviews commonly ask about: Joins (Inner, Left, Right, Full), Subqueries, Indexing, EXISTS and NOT EXISTS, IN and NOT IN, GROUP BY with HAVING, Union vs Union All, Intersect, and Minus. Revise all these before your interview.
Is TCS Managerial Round eliminatory? ▼
The TCS Managerial Round rarely eliminates candidates. It checks your attitude, flexibility, and personality. Questions include location preference, family details, and hobbies. Just be natural and honest — there are no wrong answers here.
What is the difference between TCS Digital and TCS Prime interview? ▼
Both have a similar 3-round interview structure. TCS Digital (higher package ~7 LPA) may have slightly more technical depth — especially in advanced SQL, cloud basics, and project explanation. TCS Prime is the standard fresher role (~3.36 LPA) with more general technical questions.
What coding questions come in TCS technical interview? ▼
TCS typically asks 1 basic coding question in the technical round. Common ones: find the second maximum element, reverse a string, check palindrome, print Fibonacci series, or factorial. These are medium-easy problems. Focus on logic and clean code — not advanced DSA.
Final Words
The TCS interview is not as scary as it looks from outside.
They are not trying to fail you. TCS is looking for students who are genuine, curious, and willing to learn.
You don't need to know everything. You need to know your basics well, explain your project clearly, and communicate honestly.
Know your project. Revise SQL. Practise your self-introduction. And walk in with a smile.
To help you master this area, we have compiled a complete PYQ (Previous Year Questions) set from the Number System – Day 01 and Day 02 series. These 50+ questions cover every important concept tested in real exams.
Why Focus on Number System?
Weightage in exams: Almost every company includes 2–3 direct number system questions.
Conceptual base: Topics like factors, divisibility, factorial zeros, and remainders build the logic for tougher aptitude.
High-scoring: With proper practice, these questions can be solved in less than a minute.
Number System Day 01 – PYQ Set
Q1. If 3/4 of the difference of 2 1/4 and 1 2/3 is subtracted from 2/3 of 3 1/4, the result is a) -48/83 b) 48/83 c) -83/48 d) 83/48 Answer: d) 83/48
Q2. P is the product of all prime numbers from 1 to 100. Then the number of zeros at the end of the product is a) 0 b) 1 c) 24 d) None of these Answer: b) 1
Q3. What is the highest power of 2 in 1! + 2! + 3! + … + 100!? a) 24 b) 3 c) 0 d) 97 Answer: c) 0
Q4. If n = 1 + x, where x is the product of four consecutive positive integers, then which of the following is true?
n is odd
n is prime
n is a perfect square a) 1 only b) 2 only c) 3 only d) 1 & 3 only Answer: d) 1 & 3 only
Q5. What is the maximum value of m if N = 35 × 45 × 55 × 60 × 124 × 75 is divisible by 5^m ? a) 4 b) 5 c) 6 d) 7 Answer: c) 6
Q6. The product of two consecutive even numbers is 9408. Which of the following is the greater number? a) 96 b) 94 c) 92 d) 90 e) None of these Answer: e) None of these (correct number is 98)
Q7. The sum of the digits of a two-digit number is 15 and the difference between the digits is 3. What is the number? a) 69 b) 78 c) 96 d) Cannot be determined e) None of these Answer: d) Cannot be determined (both 69 and 96 satisfy conditions)
Q8. Find the maximum number of trees which can be planted 10m apart on two sides of a straight road 1860m long. Answer: 373
Q9. A man engaged a servant for Rs. 90 + a turban for one year. He served 9 months and received Rs. 65 + turban. Find the price of the turban. Answer: Rs. 20
Q10. In a division sum, the divisor is 10 times the quotient and 5 times the remainder. If remainder = 48, find the dividend. a) 5808 b) 5809 c) 5484 d) 3472 Answer: a) 5808
Q11. If x and y are positive integers, is y odd?
x is odd.
xy is odd. Answer: Statement 2 alone is sufficient.
Q12. Is b^ab + b^(b+1) even? (a, b positive integers)
b is even
a is even Answer: Statement 1 alone is sufficient.
Q13. How many keystrokes are needed to type numbers from 1 to 1000? a) 2704 b) 2890 c) 2893 d) 3001 Answer: c) 2893
Day 02: Number System PYQ
Q1. How many divisors of 1020? a) 12 b) 20 c) 24 d) 36 Answer: c) 24
How many divisors of 1200? a) 12 b) 30 c) 24 d) 36 Answer: b) 30
Q2. For N = 420, find:
Total number of factors
Number of even factors
Number of odd factors Answer: 24 total, 16 even, 8 odd
Q3. Find total number of factors of 888888. Answer: 120
Q4. Find number of divisors of 50. Answer: 6
Q5. Find trailing zeros in 25!. Answer: 6
Q6. Division sum (same as Day01 Q13). Answer: 5808
Q7. Least value of * in 451*603 divisible by 9? Answer: 7
Q8. If 5432*7 divisible by 9, * = ? Answer: 6
Q9. When 335 is added to 5A7, the result is 8B2 (divisible by 3). Find largest & smallest A. Answer: Largest A = 9, Smallest A = 0
Q10. Find k in 9314k8025 divisible by 11. Answer: 7
Q11. If 259876P05 divisible by 11, find (P^2 + 5). Answer: 56
Q12. Which is divisible by 15? Options: 2365, 1375, 4365, 2275 Answer: 1375
Q13. Which is NOT divisible by 18? Options: 54036, 50436, 34056, 65043 Answer: 65043
Q14. Which is divisible by 24? Options: 35718, 63810, 537804, 3125736 Answer: 3125736
Q15. Least 5-digit number divisible by 52, 56, 78, 91? Answer: 10920
Q16. Greatest 6-digit number leaving remainder 10 when divided by 36, 48, 54, 60, 90? Answer: 997910
Q17. Largest 4-digit number divisible by 88? Answer: 9944
Q18. If 5432y1749x divisible by 72, find (5x – 4y). Answer: 18
Q19. N = 897324P64Q divisible by 8 and 9. Value of P + Q? Answer: 9
Q20. How many pairs (A,B) possible in 89765A4B if divisible by 9 and last digit even? Answer: 3
Q21. (271 + 272 + 273 + 274) divisible by? a) 9 b) 10 c) 11 d) 13 Answer: b) 10
Focus on logic-based questions — they repeat across exams.
Final Words
This Number System PYQ Super Set combines questions from multiple real exams. By practicing all these, you will gain the accuracy and speed required to clear the aptitude rounds of TCS, Infosys, Wipro, Accenture, Capgemini, and LTI Mindtree.
Verbal Ability Questions for Placement Exams (PYQ Super 30 with Answers)
Verbal ability is one of the most important sections in placement exams of companies like Infosys, Wipro, TCS, LTI Mindtree, Cognizant, Accenture and more. Many students prepare for aptitude and coding but underestimate verbal ability — which often has a separate cutoff.
In this blog, we bring you the Verbal Assorted Super 30 Previous Year Questions (PYQ). Practicing these questions will give you a strong edge in clearing the verbal section in upcoming 2025 placement drives.
Verbal Assorted Super 30: Questions with Answers
Question 1
The waiter hasn’t brought the chocolate shake ___ I’ve been here an hour already. a) up b) yet c) still d) till Answer: b) yet
Question 2
Everyone in this world is accountable to God ___ his actions. a) for b) about c) to d) at Answer: a) for
Question 3
She is married ___ a doctor. a) with b) to c) of d) about Answer: b) to
Question 4
We stayed at a small guest house, but the ___ was good. a) food b) accommodation c) lodging d) boarding Answer: b) accommodation
Question 5
My train is due to arrive ___ 5 o’clock. a) in b) at c) on d) for Answer: b) at
Question 6
I am tired ___ waiting. a) with b) of c) for d) about Answer: b) of
Question 7
Our school is very famous ___ its sports achievements. a) for b) with c) about d) of Answer: a) for
Question 8
The company deals ___ electrical goods. a) with b) in c) about d) on Answer: b) in
Question 9
He is angry ___ me. a) on b) of c) with d) about Answer: c) with
Question 10
He is good ___ Mathematics. a) at b) in c) with d) for Answer: a) at
Question 11
The news of his resignation was not ___ on the radio. a) broadcasted b) broadcast c) telecasted d) None Answer: b) broadcast
Question 12
She was annoyed ___ his behavior. a) about b) with c) on d) for Answer: b) with
Question 13
I am confident ___ my success. a) about b) on c) of d) for Answer: c) of
Question 14
He has a passion ___ reading. a) with b) on c) about d) for Answer: d) for
Question 15
We should not boast ___ our wealth. a) at b) for c) of d) about Answer: c) of
Question 16
He is addicted ___ gambling. a) for b) to c) with d) in Answer: b) to
Question 17
He is very fond ___ playing cricket. a) with b) of c) at d) in Answer: b) of
Question 18
Do not brood ___ your past failures. a) over b) on c) at d) for Answer: a) over
Question 19
We are looking forward ___ our holidays. a) at b) in c) for d) to Answer: d) to
Question 20
The children were playing ___ the ground. a) in b) at c) on d) with Answer: c) on
Question 21
The principal was pleased ___ my work. a) at b) with c) on d) about Answer: b) with
Question 22
She prevented me ___ going there. a) against b) from c) with d) at Answer: b) from
Question 23
The students are longing ___ vacations. a) about b) at c) for d) with Answer: c) for
Question 24
She congratulated me ___ my success. a) for b) on c) about d) of Answer: b) on
Question 25
All my advice fell ___ and he continued in his old ways. a) down b) off c) apart d) flat Answer: d) flat
Question 26
The judge listened to the arguments ___ the lawyer. a) of b) at c) by d) from Answer: a) of
Question 27
The two brothers quarreled ___ the property. a) at b) for c) with d) over Answer: d) over
Question 28
The new manager is anxious ___ quick results. a) for b) at c) with d) of Answer: a) for
Question 29
Please do not interfere ___ my business. a) in b) with c) on d) for Answer: a) in
Question 30
He is suffering ___ fever. a) with b) from c) in d) for Answer: b) from
How to Prepare for Verbal Ability
Read Daily: Newspapers, online articles, and novels help improve vocabulary and comprehension.
Maintain a Vocabulary Journal: Note down new words, their meanings, and example sentences.
Practice PYQ Regularly: As seen above, many questions repeat in placement exams with slight variations.
Grammar Revision: Brush up on tenses, subject-verb agreement, articles, prepositions, and sentence structure.
Mock Tests: Practice under time limits to improve speed and accuracy.
Key Takeaways from Verbal PYQ
Placement exams test basic but tricky English usage.
Questions often look simple but are designed to trap students with common grammar/vocabulary errors.
Consistent practice of PYQ sets like the Verbal Assorted Super 30 can significantly improve your chances of clearing the verbal section.
Infosys & LTI Exam Pattern 2025–26: Complete Guide with Section-Wise Syllabus and Sample Questions
Getting placed in companies like Infosys and LTI Mindtree is a dream for many freshers. But if you look closely at why students fail, it’s usually not because the exam is impossible — it’s because they never studied the pattern properly.
We’ll break down the Infosys System Engineer exam pattern (2025–26) and the LTI Mindtree hiring test structure, straight from the latest official material. Along the way, you’ll also see sample questions, topics to focus on, and preparation tips.
Infosys System Engineer Exam Pattern 2025–26
Infosys has a sectional cutoff system. Even if your overall score is strong, failing one section can eliminate you.
Section I: Mathematical / Technical Ability
10 questions, 35 minutes
Core areas: Number System, HCF & LCM, Percentages, Profit & Loss, SI & CI, Time-Speed-Distance, Time & Work, Pipes & Cisterns, Probability, Permutations & Combinations.
Also includes arrangement puzzles (tabular, circular, linear, square).
Sample Questions
How many code words can be formed with two distinct alphabets followed by two distinct digits?
Two containers have milk-water mixtures in ratios 5:4 and 7:9. In what ratio should they be mixed to form a 1:1 mixture?
Pipe A fills a tank in 10 hrs, Pipe B empties it in 15 hrs. How long to fill a half-empty tank?
Section II: Analytical Thinking
15 questions, 25 minutes
Topics: Syllogisms, data sufficiency, logical statements, graph-based DI, puzzles.
Sample Questions
“All green are blue. All blue are white.” → Which conclusions follow?
Find the wrong number in the series: 15972, 15629, 15840, 15720, 15784, 15757.
A round-robin tournament had 21 matches. How many teams participated?
Section III: Puzzle Solving
4 questions, 10 minutes
Matrix-based and pattern-based questions.
Example A 3×3 matrix follows a rule. Find the missing number in the middle row. Options: 169, 181, 197, 205.
Language & Pseudo Code
Although not highlighted in the PPT, Infosys SE exams also include:
English grammar (error correction, sentence completion).
Focus: Problem-solving, DS & Algo (arrays, strings, hashing), time/space complexity, test case handling
Communication Assessment
Grammar, reading comprehension, sentence correction, vocabulary in context
Sometimes includes speaking/listening (fluency, pronunciation)
Preparation Strategy
For Infosys: Prioritize aptitude speed and reasoning depth. Focus on puzzles, arrangement-based questions, and probability.
For LTI: Cover breadth — aptitude basics + computer science theory + strong coding practice.
Mock Tests: Both companies use adaptive or cutoff-based systems. Practicing under real exam conditions is key.
Conclusion
Infosys and LTI remain two of the biggest opportunities for fresh graduates in 2025–26. While Infosys leans more on aptitude + reasoning + cutoff clearing, LTI tests a broader mix of aptitude + computer science + coding.
LTI AI Interview 2025: Complete Guide, Questions, and Preparation Strategy
Recruitment at top IT companies is evolving. Gone are the days when every candidate sat across a human panel. Today, companies like LTI Mindtree are introducing AI-based interviews to streamline hiring. These interviews test not just your technical knowledge but also your communication skills, problem-solving approach, and ability to think under pressure.
If you are preparing for the LTI AI Interview 2025, this blog will walk you through the structure, common questions, and smart preparation strategies.
What is an AI-Based Interview?
An AI interview is a virtual assessment where you interact with a system rather than a human recruiter. The system records your responses, analyzes speech clarity, grammar, and content, and evaluates your coding and technical answers.
The goal is to ensure fairness, reduce interviewer bias, and assess a large number of candidates efficiently.
Flow of the LTI AI Interview
Step 1: Resume Upload & Introduction
Upload your resume to the platform.
Start with a self-introduction: your background, education, and career aspirations.
AI may pick keywords from your resume and frame questions.
Possible Prompts:
Tell me about yourself.
Walk me through your projects.
What role did you play in your project team?
What challenges did you face, and how did you overcome them?
Step 2: Resume-Based Questions
These questions check how well you know your own work. They often cover:
Project details: technology stack, your contribution.