Advanced Coding is the longest single block in TCS NQT — 2 problems in 90 minutes — and the strongest lever for a Digital or Prime offer. You write, compile and run code in the TCS iON environment, choosing from C, C++, Java, Python or Perl. Marks come from passing test cases, including hidden ones, with partial credit for partially correct solutions.
What the problems look like
Problems are typically easy-to-medium difficulty — array and string manipulation, pattern logic, simulation, and standard algorithms like LCM/GCD, sorting-based greedy choices and simple dynamic programming. Reading input in the exact format specified matters as much as the algorithm: many candidates fail test cases purely on input parsing.
Real TCS NQT coding problems
These problems appeared in recent TCS NQT papers. Try solving each one yourself before revealing the solution.
You are given two strings A and B of equal length N. In one move, choose a subset of characters from A, find the smallest letter in the subset, and replace all other characters of the subset with it. Find the minimum number of moves required to convert A into B. Return −1 if it is impossible.
Input: A = "abcab", B = "aabab"
Output: 2
Input: N = 2, A = "de", B = "cd"
Output: -1
Input: N = 4, A = "abab", B = "abaa"
Output: 1
- 1 ≤ N
- A and B consist of lowercase English letters
N students stand in a line in jersey order 1..N, each holding a board showing a position. After every drum beat, each student moves to the position shown on their board. Find the minimum number of beats after which all students return to their original positions.
Input: N = 5, Board = [2, 3, 1, 5, 4]
Output: 6
Cycles are (1→2→3→1) of length 3 and (4↔5) of length 2; LCM(3, 2) = 6.
- 1 ≤ N ≤ 100,000
- All board values are unique and in the range 1..N
Alice gives a digit to friend F[1]. Each friend passes it to the next friend down the line, and the last friend writes down what they heard. Given N friends and an array D where D[i] is the digit understood by friend i, find how many friends did NOT understand the digit correctly (the correct digit is the one Alice gave, i.e., D[1]).
Input: N = 3, D = [4, 4, 4]
Output: 0
Input: N = 5, D = [1, 2, 3, 2, 2]
Output: 4
How to maximise your coding score
- Solve the easier problem first — full marks on one beats half marks on both.
- Handle edge cases: N = 1, all-equal inputs, and impossible cases returning −1.
- Test with the sample input before submitting; then re-check the output format (no extra spaces or labels).
- If stuck on the optimal approach, submit a brute-force solution — partial test-case marks still count.


