TCS Prime Software Engineer — Greedy Correctness Proof
- Field
- Engineering
- Company
- Tata Consultancy Services
- Role
- Prime Software Engineer
- Duration
- 20 min
- Difficulty
- Hard
- Completions
- New
- Updated
- 2026-06-11
How to prepare
What this round tests, what strong and weak answers sound like, and the traps to sidestep.
What this round is about
- Topic focus. Two medium-hard problems, one interval-scheduling and one greedy array problem, at the proof-of-correctness altitude where working code alone is not enough.
- Conversation dynamic. A senior engineer on the Prime coding panel makes you justify the greedy choice, not just run it, and pushes for a counter-example when you assert optimality.
- What gets tested. Whether you can sort the input correctly, give an exchange argument for why earliest finish time wins, dry-run your code, and say when greedy breaks and dynamic programming takes over.
- Round format. You think aloud, draw the interval timeline on the whiteboard, write code on the canvas cards, and defend it verbally as the panel probes.
What strong answers look like
- Strategy before syntax. You say how you will sort the intervals and why before writing a line, for example sort by finish time and scan once keeping the last finishing time.
- Real exchange argument. You argue that if an optimal schedule skips the earliest-finishing activity, you can swap it in and be no worse off, so earliest finish is safe.
- Honest complexity. You state O of n log n dominated by the sort, point at the dominant operation, and dry-run it on the sample input rather than asserting the running time.
- Knows the boundary. You name a case like zero-one knapsack or coin change with arbitrary denominations where greedy fails and you switch to a dynamic-programming table.
What weak answers look like (and how to avoid them)
- Code without a why. Writing a correct greedy and then having nothing when asked why it is optimal. Rehearse the swap argument so the justification is automatic.
- Wrong sort key. Sorting activity selection by start time and not noticing. Always ask yourself which key leaves the most room for the rest.
- Unbacked complexity. Saying O of n log n with no dry-run to support it. Trace one small input out loud and let the count produce the bound.
- Greedy as a hammer. Treating greedy as always correct. Keep one failure case ready so you can mark the line where dynamic programming is required.
Pre-interview checklist (2 minutes before you start)
- Recall the interval setup. Have the minimum-rooms model ready: sort arrival and departure events and sweep to count concurrent meetings.
- Re-read the swap argument. Be able to state in one breath why picking the earliest finish never hurts the rest of the schedule.
- Pull up the jump-game greedy. Recall tracking the farthest reachable index and only jumping when you hit the end of the current range.
- Identify one greedy-fails case. Have zero-one knapsack or arbitrary-denomination coin change ready as the dynamic-programming boundary.
- Think of a dry-run habit. Plan to trace your code on the given sample before you claim it is correct.
How the AI behaves
- Probes every claim. Asks for the underlying argument and the dry-run, not the headline complexity, and never accepts a first answer without a follow-up.
- No mid-interview praise. It will not say great answer or validate you; it acknowledges what you said and pushes further.
- Interrupts on hand-waving. When you assert optimality without an argument, it stops and asks you to construct the input where the naive choice fails.
- Redirects, never teaches. If you freeze, it narrows to one sub-step and asks you to think aloud rather than giving you the algorithm.
Common traps in this type of round
- Silent thinking. Going quiet for long stretches; the panel reads silence as not knowing, so narrate your reasoning.
- Start-time sort trap. Defaulting to sorting by start time for activity selection and never reconsidering the key.
- Asserted optimality. Claiming the greedy is correct with no swap argument and no counter-example for the alternative.
- Complexity without trace. Quoting a running time you never validated by dry-running a small input.
- Diagram-talk mismatch. Saying one thing about the overlap while the drawn timeline shows another, with no reconciliation.
- Greedy everywhere. Failing to name any problem where greedy breaks and dynamic programming is mandatory.
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.
- 1Minimum Meeting Rooms (Interval Scheduling)
You are given a list of meetings, each with a start time and an end time. Find the minimum number of rooms required so that no two overlapping meetings are assigned to the same room. A meeting that starts exactly when another ends does not overlap with it and may reuse the room. Equivalently, this is the minimum number of railway platforms needed for a set of train arrivals and departures.
Example inputmeetings = [[0, 30], [5, 10], [15, 20]]Example output2- 1 <= number of meetings <= 10^5
- 0 <= start < end <= 10^9
- Touching endpoints (one meeting ends exactly when another starts) are not an overlap
- On the whiteboard: draw the meetings on a timeline, then sort the arrival and departure events and sweep them to mark the moment of maximum overlap, that count is your answer.
- 2Jump Game (Reachability and Minimum Jumps)
You are given an array of non-negative integers where each value is the maximum number of steps you can jump forward from that index. First decide whether you can reach the last index starting from index zero. Then find the minimum number of jumps needed to reach the last index, assuming it is reachable. Be ready to justify why the greedy scan is optimal and how it compares to a dynamic-programming solution.
Example inputarr = [2, 3, 1, 1, 4]Example outputreachable = true, minimum jumps = 2- 1 <= array length <= 10^4
- 0 <= arr[i] <= 10^5
- A zero value blocks forward progress unless an earlier index can jump over it
- On the whiteboard: write the array, then under each index annotate the farthest reachable position so far and circle the index where you are forced to spend a jump.
The full breakdown
How you're scored, the questions candidates ask most, and the research this interview is built on. Skim it — or just start the interview.
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.
- Greedy Correctness Justification28%
- Interval Modelling Rigor20%
- Greedy Versus DP Boundary18%
- Complexity Honesty16%
- Dry-Run Discipline10%
- Diagram and Verbal Alignment8%
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.
- Activity Selection Problem | Greedy Algo-1 - GeeksforGeeksgeeksforgeeks.org
- Jump Game - Minimum Jumps to Reach End - GeeksforGeeksgeeksforgeeks.org
- TCS NQT Coding Sheet - takeUforwardtakeuforward.org
- TCS Prime Interview Experience Batch 2024 | PrepInstaprepinsta.com
- TCS Interview Experience | Prime(2024) - GeeksforGeeksgeeksforgeeks.org