🎯 Curated for TCS NQT 2026 — FULL COVERAGE

Coding Mastery List

136 hand-picked questions with COMPLETE topic coverage. Solve these → Crack Digital/Prime. No gaps, no excuses.

Arrays • Strings • Number Theory • Sorting • HashMap • Sliding Window • Matrix • Trees • Graphs • DP • Greedy • Recursion • Patterns
136 Total
0 Done
136 Left
0% Progress

⚡ How to use this list

1️⃣ Solve in order — topics are arranged by TCS frequency
2️⃣ 🔴 MUST-DO = appears in almost every TCS NQT slot
3️⃣ Click any row to mark it done — progress saves locally
4️⃣ Time yourself: 30 min Easy, 45 min Medium, 60 min Hard
5️⃣ Always handle edge cases: empty input, single element, all same
6️⃣ Target: finish all 🔴 MUST-DO first → then Medium → then Hard
📊
Arrays
0/23
01
Find the Second Largest Element in an Array
Single pass, track two max values. Don't sort — O(n) required.
Must-DoEasy
GFG ↗
02
Reverse an Array
Two-pointer swap. Master both in-place and new-array methods.
Must-DoEasy
LeetCode ↗
03
Rotate Array by K Positions (Left/Right)
Reverse approach: reverse all → reverse first k → reverse rest. O(n).
Must-DoEasy
LeetCode ↗
04
Move All Zeros to End
Two-pointer: one for non-zero write pos, one for traversal.
Must-DoEasy
LeetCode ↗
05
Find Missing Number in Array (1 to N)
Sum formula: N*(N+1)/2 - sum(arr). Or XOR approach.
Must-DoEasy
LeetCode ↗
06
Find Duplicate in Array
HashSet or Floyd's cycle detection. Know both methods.
Must-DoEasy
LeetCode ↗
07
Two Sum — Find Pair with Given Sum
HashMap approach: for each num, check if (target-num) exists. O(n).
Must-DoEasy
LeetCode ↗
08
Sort Array of 0s, 1s, and 2s (Dutch National Flag)
Three-pointer: low, mid, high. Single pass O(n). TCS favourite!
Must-DoMedium
LeetCode ↗
09
Maximum Subarray Sum (Kadane's Algorithm)
Track currentMax and globalMax. Reset current when negative. THE classic.
Must-DoMedium
LeetCode ↗
10
Remove Duplicates from Sorted Array (In-place)
Two-pointer: slow writes unique, fast scans. Return new length.
Easy
LeetCode ↗
11
Merge Two Sorted Arrays
Two-pointer merge. Foundation for merge sort understanding.
Easy
LeetCode ↗
12
Find Majority Element (> N/2 times)
Boyer-Moore Voting. O(n) time, O(1) space. Very elegant.
Medium
LeetCode ↗
12b
Majority Element II (> N/3 times)
Extended Boyer-Moore: track two candidates. Verify in second pass. At most 2 results.
NewMedium
LeetCode ↗
13
Intersection of Two Arrays
HashSet approach. Handle duplicates carefully.
Easy
LeetCode ↗
14
Check if Array is Sorted and Rotated
Count breaks (where arr[i] > arr[i+1]). At most 1 break allowed.
Easy
LeetCode ↗
15
Maximum Product Subarray
Track both max and min product (negatives flip). Similar to Kadane's.
Medium
LeetCode ↗
16
Subarray Sum Equals K
Prefix sum + HashMap. Count prefix sums that differ by K.
Medium
LeetCode ↗
17
Leaders in an Array
Traverse from right, track max. Element is leader if > all right elements.
Must-DoEasy
GFG ↗
18
Next Permutation
Find rightmost ascending pair, swap, reverse suffix. Classic pattern.
Medium
LeetCode ↗
19
Longest Consecutive Sequence
HashSet: for each num, if num-1 not in set → count streak forward.
Medium
LeetCode ↗
20
Find Union & Intersection of Two Sorted Arrays
Two-pointer merge approach. Handle duplicates across both arrays.
Easy
GFG ↗
21
Best Time to Buy and Sell Stock
Track min price so far, compute profit at each day. One pass O(n). TCS classic!
NewMust-DoMedium
LeetCode ↗
22
Rearrange Positive & Negative Numbers Alternately
Separate positives/negatives, interleave. Or two-pointer partition approach.
NewTCS AskedMedium
GFG ↗
🔤
Strings
0/19
23
Check if String is Palindrome
Two-pointer from both ends. Handle case-insensitive + ignore non-alpha.
Must-DoEasy
LeetCode ↗
24
Reverse a String / Reverse Words in a String
Split by space, reverse array, join. Handle multiple spaces.
Must-DoEasy
LeetCode ↗
25
Check if Two Strings are Anagrams
Frequency count with array[26] or HashMap. Compare counts.
Must-DoEasy
LeetCode ↗
26
Count Vowels and Consonants in a String
Simple traversal. Use a set for vowel check. Handle uppercase.
Must-DoEasy
GFG ↗
27
First Non-Repeating Character
HashMap for frequency, then second pass to find first with count=1.
Must-DoEasy
LeetCode ↗
28
Most Frequent Character in a String
Frequency array. Track max frequency and corresponding char.
Must-DoEasy
GFG ↗
29
Remove All Occurrences of a Character
Simple filter/replace. Know your language's string methods.
Easy
GFG ↗
29b
Remove Duplicates from a String
Use LinkedHashSet or boolean visited[26] to keep first occurrence only.
NewEasy
GFG ↗
30
Check if String Contains Only Digits
Iterate and check ASCII range or use isdigit(). Edge: empty string.
Easy
GFG ↗
31
Longest Substring Without Repeating Characters
Sliding window + HashSet. Shrink left when duplicate found.
Must-DoMedium
LeetCode ↗
32
Count Words in a String
Split by spaces, filter empty strings, count. Handle multiple spaces.
Easy
GFG ↗
33
Longest Palindromic Substring
Expand around center for each char (odd+even length). O(n²).
Medium
LeetCode ↗
34
Group Anagrams
Sort each word as key in HashMap. Group by sorted key.
Medium
LeetCode ↗
35
Check if One String is a Rotation of Another
Concatenate s1+s1, then check if s2 is a substring. Clever O(n).
Easy
GFG ↗
36
Remove Vowels from a String
Filter out vowels. Simple but TCS asks variants frequently.
TCS AskedEasy
GFG ↗
37
String Compression (Run-Length Encoding)
Count consecutive chars: "aabbbcc" → "a2b3c2". Watch output format.
TCS AskedEasy
LeetCode ↗
38
Longest Common Prefix
Compare char by char across all strings. Stop at first mismatch.
Easy
LeetCode ↗
39
Valid Parentheses (Balanced Brackets)
Use a stack. Push opening, pop on closing and match. Classic.
TCS AskedMedium
LeetCode ↗
40
Roman to Integer / Integer to Roman
Map roman chars to values. If smaller before larger → subtract.
Medium
LeetCode ↗
🔢
Number Theory & Math
0/17
41
Check if Number is Prime
Check divisibility up to √n only. Handle n=0,1 edge cases.
Must-DoEasy
GFG ↗
42
Reverse a Number / Check Palindrome Number
Build reversed number digit by digit. Compare with original.
Must-DoEasy
LeetCode ↗
43
Fibonacci Series (Iterative + Recursive + DP)
Know all 3 approaches. Iterative is O(n) time O(1) space. Best for TCS.
Must-DoEasy
LeetCode ↗
44
Factorial of a Number (Iterative + Recursive)
Simple loop. Watch overflow for large N — use long/BigInteger.
Must-DoEasy
GFG ↗
45
GCD and LCM of Two Numbers
Euclidean algorithm: gcd(a,b) = gcd(b, a%b). LCM = (a*b)/gcd.
Must-DoEasy
GFG ↗
46
Armstrong Number Check
Sum of digits^(number of digits) == number itself. 153 → 1³+5³+3³=153.
Must-DoEasy
GFG ↗
47
Strong Number Check
Sum of factorial of digits == number. 145 → 1!+4!+5!=145.
TCS AskedEasy
GFG ↗
48
Perfect Number Check
Sum of proper divisors == number. 6 → 1+2+3=6.
TCS AskedEasy
GFG ↗
49
Sum of Digits / Digital Root / Number of Digits
Extract digits with %10 and /10. Digital root: keep summing till single digit. Count digits with log10.
Must-DoEasy
GFG ↗
50
Decimal to Binary / Binary to Decimal Conversion
Use repeated /2 and %2 for D→B. Positional multiplication for B→D.
TCS AskedEasy
GFG ↗
51
Sieve of Eratosthenes (All Primes up to N)
Boolean array, mark multiples of each prime. O(n log log n).
Medium
LeetCode ↗
52
Power of Two / Power of Three Check
Bit manipulation: n & (n-1) == 0 for power of 2. Or keep dividing.
Easy
LeetCode ↗
53
Count Trailing Zeros in Factorial
Count factors of 5 in N!: N/5 + N/25 + N/125 + ...
Easy
LeetCode ↗
54
Modular Exponentiation (Power with Modulo)
Binary exponentiation: square and multiply. Needed for large inputs.
Medium
GFG ↗
55
Neon Number / Spy Number / Automorphic Number
TCS loves these number-type checks. Quick implementations.
TCS AskedEasy
GFG ↗
56
Count Factors / Divisors of a Number
Loop from 1 to √n, if n%i==0, count both i and n/i. O(√n).
NewTCS AskedEasy
GFG ↗
57
Count Number of Digits in a Number
Use log10(n)+1 or repeated /10 loop. Handle n=0 edge case.
NewEasy
GFG ↗
🔍
Sorting & Searching
0/10
58
Binary Search (Iterative + Recursive)
left=0, right=n-1, mid=(left+right)/2. Know both implementations cold.
Must-DoEasy
LeetCode ↗
59
Search in Rotated Sorted Array
Modified binary search: check which half is sorted, then decide.
Must-DoMedium
LeetCode ↗
60
Find First and Last Position of Element
Two binary searches: one for leftmost, one for rightmost occurrence.
Medium
LeetCode ↗
61
Bubble Sort Implementation
Know the algorithm, time complexity O(n²). TCS asks to implement sorts.
Must-DoEasy
GFG ↗
62
Selection Sort Implementation
Find min in unsorted part, swap to front. O(n²) but easy to code.
Easy
GFG ↗
63
Merge Sort Implementation
Divide and conquer. O(n log n). Understand merge step thoroughly.
Medium
GFG ↗
64
Find Peak Element
Binary search: if mid > mid+1, peak is on left side (including mid).
Medium
LeetCode ↗
65
Find Square Root (Integer) using Binary Search
Binary search between 1 and n. Check mid*mid <= n < (mid+1)*(mid+1).
Medium
LeetCode ↗
66
Find Floor and Ceil of a Number in Sorted Array
Modified binary search. Floor: largest ≤ target. Ceil: smallest ≥ target.
Easy
GFG ↗
67
Kth Smallest/Largest Element
Use QuickSelect O(n) avg or sort+index O(n log n). Know both.
Medium
LeetCode ↗
🗂️
HashMap & Frequency Counting
0/9
68
Frequency of Each Element in Array
HashMap: key=element, value=count. Print all. Foundation skill.
Must-DoEasy
GFG ↗
69
Find All Duplicates in an Array
HashMap count > 1. Or mark visited by negating index (O(1) space trick).
Must-DoEasy
LeetCode ↗
70
Check if Two Arrays are Equal
Compare frequency maps. Handle duplicates properly.
Easy
GFG ↗
71
Top K Frequent Elements
HashMap for frequency → sort by freq → return top K. Or bucket sort.
Medium
LeetCode ↗
72
Count Pairs with Given Sum
For each element, check if (sum - element) exists in map. Handle duplicates.
TCS AskedMedium
GFG ↗
73
First Element to Occur K Times
HashMap: increment count on each element. Return first with count == K.
TCS AskedMedium
GFG ↗
74
Longest Subarray with Sum K (Positives + Negatives)
Prefix sum + HashMap. Store first occurrence of each prefix sum.
Medium
GFG ↗
75
Contains Duplicate II (Within K Distance)
Sliding window with HashSet of size K. Or HashMap storing last index.
Medium
LeetCode ↗
76
Count Distinct Elements in Array
Insert all elements into HashSet. Set size = distinct count. O(n).
NewEasy
GFG ↗
🪟
Sliding Window & Two Pointer
0/8
77
Maximum Sum Subarray of Size K
Fixed-size sliding window: add right, subtract left. O(n).
Must-DoMedium
GFG ↗
78
Smallest Subarray with Sum ≥ S
Variable-size window: expand right, shrink left when sum ≥ S. Track min.
Medium
LeetCode ↗
79
Count Subarrays with Given XOR / Sum
Prefix sum/XOR + HashMap for counting. Important pattern.
Medium
GFG ↗
80
Container With Most Water
Two-pointer from both ends. Move shorter pointer inward. O(n).
Medium
LeetCode ↗
81
3Sum (Find All Triplets with Sum = 0)
Sort → fix one → two-pointer for remaining. Skip duplicates.
Medium
LeetCode ↗
82
Move Negative Numbers to One Side
Two-pointer partition. Similar to Dutch flag but simpler.
TCS AskedEasy
GFG ↗
83
Trapping Rain Water
Two-pointer or prefix max arrays. Calculate water at each index. Classic.
Hard
LeetCode ↗
84
Minimum Window Substring
Variable window + frequency map. Expand right to cover all chars, shrink left to minimize. O(n).
NewHard
LeetCode ↗
🔲
Matrix Operations
0/8
85
Transpose of a Matrix
Swap matrix[i][j] with matrix[j][i]. For in-place: only upper triangle.
Must-DoEasy
GFG ↗
86
Spiral Order Matrix Traversal
4 pointers: top, bottom, left, right. Traverse boundaries, shrink inward.
Must-DoMedium
LeetCode ↗
87
Rotate Matrix by 90 Degrees
Transpose + reverse each row. In-place O(1) space.
Medium
LeetCode ↗
88
Set Matrix Zeroes
Use first row/col as markers. Two-pass approach. O(1) space.
Medium
LeetCode ↗
89
Matrix Multiplication
Triple nested loop: C[i][j] += A[i][k] * B[k][j]. Know dimensions rule.
TCS AskedEasy
GFG ↗
90
Search in Sorted 2D Matrix
Start top-right. If target < current go left, else go down. O(m+n).
Medium
LeetCode ↗
91
Diagonal Traversal of Matrix
Primary diagonal: i==j. Secondary: i+j==n-1. Traverse both diagonals separately.
NewEasy
GFG ↗
92
Row-wise and Column-wise Sum of Matrix
Nested loops: sum each row and each column separately. TCS basic matrix question.
NewTCS AskedEasy
GFG ↗
🌳
Trees (For Prime)
0/10
93
Inorder, Preorder, Postorder Traversal (Recursive + Iterative)
Know all 3 traversals cold. Recursive is easy, iterative uses stack. Foundation of trees.
NewMust-DoEasy
LeetCode ↗
94
Level Order Traversal (BFS on Tree)
Use a queue. Process level by level. Foundation for many tree problems.
NewMust-DoEasy
LeetCode ↗
95
Height / Maximum Depth of Binary Tree
Recursive: max(left, right) + 1. Base: null → 0. Classic DFS.
NewMust-DoEasy
LeetCode ↗
96
Check if Binary Tree is Balanced
Height difference of left & right subtrees ≤ 1 at every node. O(n) with combined height check.
NewEasy
LeetCode ↗
97
Diameter of Binary Tree
Longest path between any two nodes. At each node: leftHeight + rightHeight. Track global max.
NewMust-DoMedium
LeetCode ↗
98
Mirror / Symmetric Tree Check
Recursive: left.left mirrors right.right and vice versa. Clean base cases.
NewEasy
LeetCode ↗
99
Lowest Common Ancestor (LCA) of Binary Tree
If both nodes found in left/right → current node is LCA. Classic recursion.
NewMedium
LeetCode ↗
100
Validate Binary Search Tree (BST)
Inorder traversal must be sorted. Or pass min/max bounds recursively. Important BST concept.
NewMust-DoMedium
LeetCode ↗
101
Search & Insert in BST
Search: compare and go left or right. Insert: find null position. Know both recursive & iterative.
NewEasy
LeetCode ↗
102
Left View / Right View / Top View of Binary Tree
Level order + track first/last node per level. Or recursive with depth tracking.
NewMedium
GFG ↗
🕸️
Graphs (For Prime)
0/8
103
BFS (Breadth-First Search) on Graph
Queue-based traversal. Use visited array. Level-by-level exploration. Foundation of graph problems.
NewMust-DoMedium
GFG ↗
104
DFS (Depth-First Search) on Graph
Stack or recursion. Mark visited. Explore as deep as possible before backtracking.
NewMust-DoMedium
GFG ↗
105
Detect Cycle in Undirected Graph
BFS/DFS + parent tracking. If visited neighbor ≠ parent → cycle exists.
NewMust-DoMedium
GFG ↗
106
Detect Cycle in Directed Graph
DFS with recursion stack (3-color: white/gray/black). Gray→Gray = cycle.
NewMedium
GFG ↗
107
Number of Islands (Connected Components)
Grid DFS/BFS: for each unvisited '1', start traversal and mark all connected. Count components.
NewMust-DoMedium
LeetCode ↗
108
Shortest Path in Unweighted Graph (BFS)
BFS naturally finds shortest path in unweighted graphs. Track distance array.
NewMedium
GFG ↗
109
Topological Sort (Kahn's BFS / DFS)
DAG ordering: process nodes with 0 in-degree first. Or DFS with post-order stack.
NewMedium
GFG ↗
110
Dijkstra's Shortest Path (Weighted Graph)
Min-heap + greedy relaxation. dist[src]=0, relax neighbors. O((V+E) log V).
NewMedium
GFG ↗
💎
Dynamic Programming (For Prime)
0/12
111
Climbing Stairs (Fibonacci DP)
dp[i] = dp[i-1] + dp[i-2]. Base: dp[0]=1, dp[1]=1. Classic intro to DP.
Must-DoEasy
LeetCode ↗
112
0/1 Knapsack Problem
2D DP: dp[i][w] = max(exclude, include). Can optimize to 1D.
Medium
GFG ↗
113
Longest Common Subsequence (LCS)
2D table: if chars match dp[i][j]=dp[i-1][j-1]+1, else max of top/left.
Medium
LeetCode ↗
114
Coin Change (Min Coins)
1D DP: dp[amount] = min coins. For each coin, dp[j] = min(dp[j], dp[j-coin]+1).
Medium
LeetCode ↗
115
Longest Increasing Subsequence (LIS)
O(n²) DP or O(n log n) with binary search. Know both.
Medium
LeetCode ↗
116
House Robber (Max Non-Adjacent Sum)
dp[i] = max(dp[i-1], dp[i-2]+nums[i]). Simple 1D DP.
Easy
LeetCode ↗
117
Min Path Sum in Grid
dp[i][j] = grid[i][j] + min(dp[i-1][j], dp[i][j-1]). Standard 2D DP.
Medium
LeetCode ↗
118
Edit Distance
2D DP on two strings. 3 operations: insert, delete, replace. Classic.
Hard
LeetCode ↗
119
Subset Sum Problem
dp[i][j] = can we form sum j using first i items? Boolean 2D DP. Key knapsack variant.
NewMust-DoMedium
GFG ↗
120
Unique Paths in Grid
dp[i][j] = dp[i-1][j] + dp[i][j-1]. Count ways to reach bottom-right from top-left.
NewMedium
LeetCode ↗
121
Palindrome Partitioning (Min Cuts)
dp[i] = min cuts for s[0..i] to be all palindromes. Pre-compute palindrome check table.
NewHard
LeetCode ↗
122
Word Break Problem
dp[i] = can s[0..i] be segmented? For each j
NewMedium
LeetCode ↗
🎯
Greedy
0/4
123
Activity Selection Problem
Sort by end time. Pick first, skip overlapping, pick next non-overlapping.
Easy
GFG ↗
124
Fractional Knapsack
Sort by value/weight ratio. Take as much as possible of most valuable.
Easy
GFG ↗
125
Minimum Coins for Change (Greedy Approach)
For standard denominations, greedy works. Pick largest coin first.
TCS AskedMedium
GFG ↗
126
Pattern Printing (Number/Star Triangles)
Nested loops: outer for rows, inner for spaces + stars. 5-6 patterns.
TCS AskedEasy
GFG ↗
🔁
Recursion & Backtracking
0/6
127
Generate All Subsets (Power Set)
Recursive: include/exclude each element. Or bitmask iteration.
Medium
LeetCode ↗
128
Generate All Permutations of a String/Array
Recursive swap at each position. Backtrack after recursive call.
Medium
LeetCode ↗
129
Tower of Hanoi
Move n-1 to aux, move nth to dest, move n-1 to dest. Classic recursion.
TCS AskedEasy
GFG ↗
130
Print All Subsequences of a String
Include/exclude recursion. 2^n subsequences total.
Easy
GFG ↗
131
Sum of Digits using Recursion
Base: n==0 return 0. Recursive: n%10 + sumOfDigits(n/10). Pure recursion practice.
NewEasy
GFG ↗
132
Reverse String / Array using Recursion
Swap first and last, recurse on inner. Base: start >= end. O(n).
NewEasy
GFG ↗
🧩
Pattern / Simulation (TCS Favorite)
0/2
133
Clock Angle Problem
Hour hand moves 0.5°/min, minute hand moves 6°/min. Find abs difference.
TCS AskedEasy
GFG ↗
134
Game Simulation / Matrix Transformation Logic
Read problem carefully, simulate step-by-step. No trick — just clean implementation.
TCS AskedMedium
GFG ↗