TCS Digital Software Engineer — Linked List and Stack Pointer Drill
- Field
- Engineering
- Company
- Tata Consultancy Services
- Role
- Digital Software Engineer Trainee
- Duration
- 20 min
- Difficulty
- Hard
- Completions
- New
- Updated
- 2026-06-09
What this round is about
- Topic focus. Two linear-structure problems: a singly linked-list reversal you trace pointer by pointer, then a stack-based check for balanced parentheses.
- Conversation dynamic. A senior Digital panellist makes you draw and walk a small example on the whiteboard before you write any code, then pushes on edge cases and complexity.
- What gets tested. Pointer discipline, correct handling of the empty and single-node cases, big-O reasoning, and your justification for choosing one structure over another.
- Round format. Twenty minutes, voice plus a shared diagram canvas, calibrated to the higher TCS Digital tier rather than the base coding round.
What strong answers look like
- Trace before code. You draw the list and say what each pointer does, for example: I save next, point current back to prev, then advance both.
- Pointer integrity. You never lose the tail of the list because you save the next node before rewiring the current node.
- Edge cases named unprompted. You state that an empty list returns null and a single-node list returns itself before anyone asks.
- Complexity stated plainly. You close with O(n) time and O(1) space for the iterative reversal and explain why the recursive version costs O(n) space.
What weak answers look like (and how to avoid them)
- Code-first guessing. Jumping into syntax without a trace; avoid it by drawing the starting list first and walking one input by hand.
- Lost-tail bug. Overwriting the next pointer before saving it, which orphans the rest of the list; save next into a temporary first.
- Frozen on empties. Crashing on the empty or single-node case; decide their return value before writing the loop.
- Name without trace. Saying Floyd's algorithm or stack without showing the steps; always demonstrate the movement on the board.
Pre-interview checklist (2 minutes before you start)
- Recall the three pointers. Have prev, current, and next clear in your head for the iterative reversal.
- Have the dummy-node trick ready. Remember it removes the special case when the node to remove is the head.
- Think of the two orderings. Be ready to say why last-in-first-out fits nested brackets and first-in-first-out does not.
- Identify the empty and single-node returns. Know what each problem returns on those inputs before you code.
- Pull up the whiteboard early. Plan to draw the starting structure in your first turn, not the syntax.
- Re-read the complexity claim. Be ready to defend why iterative reversal is O(1) space and recursion is not.
How the AI behaves
- Pushes you to the board. Redirects you to sketch within the first two turns if you start narrating without drawing.
- Probes every claim. Asks for the complexity and the edge-case behaviour, not just the headline approach.
- No mid-interview praise. Will not say great answer or validate; it acknowledges the specific move and pushes deeper.
- Interrupts on hand-waving. Stops you when you say and then I reverse it and asks for the exact pointer steps.
Common traps in this type of round
- Overwriting next too early. Losing the remainder of the list during reversal because the next node was not saved.
- Single-node blind spot. Forgetting that a one-node list and an empty list need explicit handling.
- Complexity guess. Stating a big-O figure that does not match the code just written on the board.
- Wrong structure justification. Claiming a queue validates brackets, or being unable to say why a stack does.
- Recursion without limits. Proposing recursive reversal without acknowledging the stack-overflow risk on a very long list.
- Algorithm name as a shield. Citing Floyd's tortoise and hare without tracing the slow and fast pointers on an example.
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.
- 1Reverse a Singly Linked List
Given the head of a singly linked list, reverse the list by changing the next pointers of each node, and return the new head. Do it iteratively, then describe the recursive version. Trace the three pointers on a small example before coding and state the time and space complexity of each approach.
Example inputhead = 1 -> 2 -> 3 -> 4 -> nullExample output4 -> 3 -> 2 -> 1 -> null- The list may be empty (head is null) or contain a single node; both must be handled cleanly.
- Iterative solution must use O(1) extra space; save the next node before rewiring the current node's pointer.
- State the time complexity (O(n)) and explain why the recursive version uses O(n) space on the call stack.
- Draw the three-pointer state (prev, current, next) on the canvas after each step of the reversal.
- 2Valid Parentheses (Balanced Brackets)
Given a string containing the characters round, square and curly brackets, determine whether the brackets are balanced and correctly nested. Choose a data structure, justify it in terms of last-in-first-out ordering, and handle the case where brackets are left unclosed at the end.
Example inputs = "([]{})" and s = "([)]"Example outputtrue for "([]{})", false for "([)]"- Use a stack: push each opening bracket and pop to match each closing bracket against its expected opener.
- After the final character, the stack must be empty; an unclosed opening bracket makes the string invalid.
- State the time complexity (O(n)) and the worst-case space (O(n)) when all characters are opening brackets.
- Draw the stack contents on the canvas as you process the input ([)] and mark the exact character where the mismatch is detected.
Interview framework
You will be scored on these 5 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.
- Pointer Trace Discipline20%
- Pointer Integrity Under Rewiring18%
- Linear Structure Edge Case Coverage18%
- Asymptotic Complexity Reasoning16%
- Data Structure Choice Justification16%
- Explain Before Code Clarity12%
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 Digital Interview Questions | GeeksforGeeks (Interview Experiences)geeksforgeeks.org
- Top 40 TCS Coding Interview Questions and Answers [2026] | Internshalainternshala.com
- TCS Digital Coding Question: Top 5 Coding Questions & Solution | Unstopunstop.com
- TCS Digital Interview Questions and Answers 2026 | PrepInstaprepinsta.com
- My TCS NQT Digital Role Interview Experience (2025) — Selected | Mediummedium.com