Tata Consultancy Services Ninja Coding Drill — Arrays, Strings and Patterns
- Field
- Engineering
- Company
- Tata Consultancy Services
- Role
- Assistant System Engineer Trainee (Ninja)
- Duration
- 20 min
- Difficulty
- Medium
- Completions
- New
- Updated
- 2026-06-09
What this round is about
This is a 20-minute live coding drill that mirrors the easy-to-medium band of the TCS NQT coding section and the live write-this-program ask inside the Ninja technical interview. You will work through two problems on screen: a pattern printing problem and an array manipulation problem. The interviewer will ask you to trace each problem on the whiteboard before you code, explain your logic after, and handle boundary inputs including cases not in the sample. One follow-up will ask you to improve your first working solution.
What strong answers look like
Strong candidates read the full problem statement before writing any code. They trace through a small example on the whiteboard — writing out variable states row by row or element by element — before touching the keyboard. They code the solution cleanly, then immediately name the complexity without being asked. When asked about boundary inputs they think through the limits systematically rather than guessing. On the improvement follow-up they make a genuine attempt: they identify what is redundant in their first solution and propose a change, even if incomplete. They explain every line of their code when asked to walk through it.
What weak answers look like (and how to avoid them)
Weak candidates jump straight to coding before tracing. Their code produces the right output on the provided numbers but breaks on an all-identical list or a one-element list because they never considered those states. They say their solution is one-pass but quietly called sort() at line one. They cannot say how fast the code runs and say it is efficient without a number. On the improvement ask they give up immediately rather than attempting even a partial change. The fix for all of these is the same: read the full statement, trace before you code, and think out loud throughout.
Pre-interview checklist (2 minutes before you start)
- Open the canvas card for Problem 1 and read the full statement including the output format before saying anything.
- Choose the programming language you are most comfortable with — do not try a new language in this session.
- Have a plan for describing how fast your code runs: know linear time, quadratic time, and log-linear time as phrases you can say out loud.
- Remind yourself: trace on the whiteboard first, then code. Not the other way around.
How the AI behaves
The AI is Arvind Nair, a Senior Technical Panelist at TCS Pune running your TR+MR round. He will not coach you or tell you what performance he is looking for. He will interrupt if you try to code without tracing first. He will probe boundary inputs and will ask one improvement follow-up. He stays in character throughout and will not tell you if you got the answer right mid-session.
Common traps in this type of round
- Calling sort() inside a solution you claim is one-pass — the interviewer will catch this and it signals a gap in performance awareness.
- Tracing only the provided example and never considering what happens for n equals 0 or an array with a single element.
- Giving up on the improvement ask without attempting anything — even a partial improvement attempt scores better than silence.
- Writing code you cannot explain — if you cannot walk through it line by line, the interviewer assumes you copied or guessed.
Sample problems you'll face
The 2 problems below are the same ones you'll work through in the live session — no surprises. Read the constraints carefully; the AI persona will refer you to the on-canvas card by problem number.
- 1Floyd's Triangle Pattern
Print Floyd's triangle for n rows: row i holds i consecutive integers continuing from where the previous row stopped (row 1 = 1; row 2 = 2 3; row 3 = 4 5 6; ...). Read n and print the triangle.
Example inputn = 4Example output1 2 3 4 5 6 7 8 9 10- 1 <= n <= 50
- Use nested loops with a running counter carried across rows
- State the time complexity in terms of the total numbers printed
- Dry-run n = 3 on the whiteboard before you write code
- Use the on-canvas card to read the prompt; sketch or write code on the whiteboard. The AI sees what you draw.
- 2Second Largest Element (Single Pass)
Given an array of integers, return the second-largest DISTINCT value in a single pass, without fully sorting the array. If no valid second-largest exists, say so.
Example input[12, 35, 1, 10, 35, 1]Example output12 (35 is largest; 12 is the second-largest distinct value)- 2 <= array length <= 10^5
- Single pass — track largest and secondLargest as you scan
- Handle duplicates of the maximum and arrays with fewer than 2 distinct values
- State time O(n) and space O(1)
- Use the on-canvas card to read the prompt; sketch or write code on the whiteboard. The AI sees what you draw.
Interview framework
You will be scored on these 6 dimensions. The full rubric with definitions is below.
What we evaluate
Your final scorecard breaks down across these dimensions. The full rubric and tier criteria are revealed inside the interview itself.
- Dry-Run Process Discipline22%
- Coding Correctness Under Observation22%
- Complexity Articulation18%
- Edge Case Coverage18%
- Optimisation Attempt Quality12%
- Code Walkthrough Accuracy8%
Common questions
Sources this interview is built on
Real candidate-report URLs (Glassdoor / AmbitionBox / PrepInsta / GeeksforGeeks / Medium) reviewed when authoring the questions, persona, and rubric. Verify the realism yourself.
- TCS NQT Coding Questions and Answers 2026 | PrepInstaprepinsta.com
- TCS Ninja Interview Experience for 2026 Batch | PrepInstaprepinsta.com
- TCS NQT Coding Sheet - GeeksforGeeksgeeksforgeeks.org
- TCS NQT Preparation Sheet 2026 - GeeksforGeeksgeeksforgeeks.org
- TCS NINJA Profile Interview Questions | Glassdoorglassdoor.co.in
- TCS Ninja Final Interview All India Campus | GeeksforGeeksgeeksforgeeks.org
- TCS NQT Coding Sheet - Takeuforwardtakeuforward.org