TCS CodeVita Questions from Previous Editions (With Solutions)
TCS CodeVita is a global coding contest separate from TCS NQT. Covers problem categories, verified sample problems, and a prep roadmap across recent CodeVita editions.
TCS CodeVita is a global competitive programming contest that runs on a separate track from TCS NQT campus hiring, and the two test very different things.
NQT selects students for Ninja, Digital, and Prime roles through aptitude plus a coding section that tests standard algorithm competency. CodeVita asks you to solve five to six problems of increasing complexity in a timed contest environment, typically against competitors from over 50 countries. The target audience, the preparation, and the outcome are all different.
That said, many engineering students in India search for “TCS CodeVita questions asked in previous editions” expecting to find a pattern they can memorise and apply. This guide addresses that honestly: CodeVita problems are not templated, but there are identifiable algorithm families that appear repeatedly across editions. Recognising those families is where preparation actually starts.
What CodeVita Is and How It Differs from TCS NQT
The TCS CodeVita portal describes the contest as one of the world’s largest coding competitions. It typically runs in three phases: an open qualification round (available to students and working professionals), a zonal round for qualifiers, and a global final for the top performers from each zone.
CodeVita Season 12 ran in 2024. Whether you are preparing for Season 13 or a later edition, the structure and problem patterns across recent seasons remain consistent enough to build a sensible prep plan around.
Here is how CodeVita compares to TCS NQT at a glance:
| Dimension | TCS CodeVita | TCS NQT |
|---|---|---|
| Purpose | Global programming contest | Campus placement screening |
| Eligibility | Students, recent graduates, professionals | Final-year and pre-final-year students (India) |
| Problem type | Algorithmic puzzles, no fixed pattern | Aptitude, coding, verbal, reasoning |
| Difficulty | Medium to Hard (LeetCode scale) | Easy to Medium (LeetCode scale) |
| Outcome for top performers | Expedited TCS interview invitation | Shortlisted for Ninja, Digital, or Prime track |
| Hiring guarantee | None | Yes, if all subsequent rounds are cleared |
The key practical point: CodeVita rank does not replace NQT. A student targeting a TCS placement through campus hiring still needs to clear NQT, regardless of CodeVita performance. See the TCS Ninja questions and mock test guide for the NQT-specific preparation track.
CodeVita is worth pursuing for three reasons separate from direct placement. First, the problems build genuine algorithmic depth that transfers to technical interviews everywhere. Second, a top-500 global rank carries weight on a resume in a way that a mock-test score does not. Third, TCS does extend interview fast-tracks to high-ranking CodeVita contestants, which can supplement or accelerate the standard NQT path.
Problem Categories Across CodeVita Editions
Contestant post-mortems and problem archives from recent CodeVita seasons reveal six algorithm families that appear with high frequency. These are not exhaustive, but a student who handles all six with reasonable fluency will solve at least two problems in the qualification round.
| Category | Core Topics | Common Sub-types |
|---|---|---|
| Graph algorithms | BFS, DFS, shortest paths | Articulation points, bridges, connected components |
| Dynamic programming | Memoization, tabulation | Longest paths, partition problems, state-space DP |
| Number theory | Primality, modular arithmetic | Sieve of Eratosthenes, GCD/LCM, prime factorisation |
| Greedy algorithms | Priority queues, activity selection | Max-heap reductions, interval scheduling |
| String processing | Pattern matching, parsing | Grid-to-character mapping, lexicographic ordering |
| Data structures | Heaps, segment trees, BITs | Range queries, order statistics, sliding windows |
A few observations from the problem history:
- Graph problems in CodeVita frequently involve non-obvious graph construction. The input does not always present an explicit adjacency list. The contestant must model the problem as a graph first.
- DP problems tend to combine standard recurrences with unusual state definitions. Recognising the state is harder than writing the transition.
- Number theory problems are often the “entry-level” problems in a CodeVita set, but they reward students who have the Sieve of Eratosthenes implemented and tested before contest day, not during.
For the standard TCS NQT coding round, the problem patterns are tighter and more predictable. The TCS coding questions guide covers that track separately.
Sample Problems with Verified Solutions
The following four problems are drawn from previous CodeVita editions. Every solution below has been re-derived from first principles, not copied from the original source.
Prime Time Again
- Problem summary: Given D (hours per day) and P (number of parts per day), find how many hour values h (where
1 <= h <= D/P) satisfy the property that h,h + D/P,h + 2*(D/P), …,h + (P-1)*(D/P)are ALL prime. - Key insight: Generate all primes up to D using the Sieve of Eratosthenes. For each h from 1 to
D/P, check if every element in the sequence is prime. - Verified solution for D=24, P=2 (so D/P = 12):
- Check h=1: 1 is not prime. Skip.
- Check h=2: 2 is prime, but 2+12=14=2x7, not prime. Skip.
- Check h=3: 3 is prime, but 3+12=15=3x5, not prime. Skip.
- Check h=5: 5 is prime, 5+12=17 is prime. Both prime. Count this.
- Check h=7: 7 is prime, 7+12=19 is prime. Both prime. Count this.
- Check h=11: 11 is prime, 11+12=23 is prime. Both prime. Count this.
- Verified answer: 3
- Cross-check with D=36, P=3 (D/P = 12): Need h, h+12, and h+24 all prime. h=5 gives 5, 17, 29 (all prime). h=7 gives 7, 19, 31 (all prime). h=11 gives 11, 23, 35=5x7 (fails). Verified answer: 2 (matches the sample output in the problem statement).
Minimum Gifts
- Problem summary: N employees stand in a line, each with a rank. Distribute the minimum number of gifts such that every employee receives at least 1 gift, and any employee with a strictly higher rank than a direct neighbour receives more gifts than that neighbour.
- Key insight: Two-pass greedy. Left-to-right pass: if rank[i]
>rank[i-1], set gifts[i] = gifts[i-1]+1, else set gifts[i] = 1. Right-to-left pass: if rank[i]>rank[i+1], set gifts[i] = max(gifts[i], gifts[i+1]+1). Sum the final array. - Verified solution for ranks = [1, 2, 1, 5, 2]:
- Start: [1, 1, 1, 1, 1]
- Left-to-right pass:
- i=1: 2
>1, so gifts[1] = 1+1 = 2 - i=2: 1
<2, so gifts[2] = 1 - i=3: 5
>1, so gifts[3] = 1+1 = 2 - i=4: 2
<5, so gifts[4] = 1 - After left pass: [1, 2, 1, 2, 1]
- i=1: 2
- Right-to-left pass:
- i=3: 5
>2, gifts[3] = max(2, 1+1) = 2 (no change) - i=2: 1
<5, no change - i=1: 2
>1, gifts[1] = max(2, 1+1) = 2 (no change) - i=0: 1
<2, no change - After right pass: [1, 2, 1, 2, 1]
- i=3: 5
- Total = 1+2+1+2+1 = 7
- Cross-check for ranks = [1, 2]:
- Left pass: [1, 2]. Right pass: no change. Total = 1+2 = 3
- Verified answers: 7 and 3 (match the sample outputs in the problem statement).
Minimize the Sum
- Problem summary: Given an array of N integers and a limit K, perform at most K operations (each operation replaces any element arr[i] with
floor(arr[i]/2)). Minimise the final sum. - Key insight: Always reduce the current maximum. A max-heap (priority queue) achieves this in O(K log N).
- Verified solution for array = [20, 7, 5, 4], K = 3:
- Operation 1: max = 20, replace with floor(20/2) = 10. Array: [10, 7, 5, 4], sum = 26.
- Operation 2: max = 10, replace with floor(10/2) = 5. Array: [5, 7, 5, 4], sum = 21.
- Operation 3: max = 7, replace with floor(7/2) = 3. Array: [5, 3, 5, 4], sum = 17.
- Verified answer: 17 (matches the sample output).
Consecutive Prime Sum
- Problem summary: Count how many prime numbers P in the range [3, N] can be expressed as a sum of consecutive primes starting from 2 (i.e., 2+3, 2+3+5, 2+3+5+7, and so on).
- Key insight: Compute prefix sums of the prime sequence starting at 2. At each step, check whether the running sum is itself prime. Count only those that fall within [3, N].
- Verified enumeration:
- sum = 2 (not in range ≥ 3, skip)
- sum = 2+3 = 5, prime. Count.
- sum = 5+5 = 10 = 2x5, not prime. Skip.
- sum = 10+7 = 17, prime. Count.
- sum = 17+11 = 28 = 4x7, not prime. Skip.
- sum = 28+13 = 41, prime. Count.
- sum = 41+17 = 58 = 2x29, not prime. Skip.
- sum = 58+19 = 77 = 7x11, not prime. Skip.
- sum = 77+23 = 100 = 4x25, not prime. Skip.
- sum = 100+29 = 129 = 3x43, not prime. Skip.
- sum = 129+31 = 160, not prime. Skip.
- sum = 160+37 = 197, prime. Count.
- Verified: primes qualifying up to N=100 are 5, 17, and 41. Count = 3.
These four problems represent the breadth of what CodeVita expects. Knowing the algorithm is not the whole job. Implementing it within a time limit, on an unfamiliar input specification, with edge cases the problem setter chose deliberately, is what separates contestants who solve two problems from those who solve four.
For a comparison against the TCS NQT coding round format, which tests a narrower range of patterns, see the TCS coding questions and answers guide.
Preparing for CodeVita: A 16-Week Approach
Sixteen weeks is enough to go from basic competitive programming competency to a score in the qualification round. The plan below is paced for a student who can commit 8 to 10 hours per week.
Weeks 1 to 4: Foundations
- Implement a clean Sieve of Eratosthenes and test it on edge cases (
n=1,n=2, largen). - Drill sorting algorithms beyond built-ins: merge sort and heap sort so you understand the heap property, not just
priority_queue. - Practice 20 to 30 LeetCode Easy problems in your primary language. Target: zero syntax bugs, no time extensions.
Weeks 5 to 8: Graphs and Trees
- BFS and DFS from scratch. Then: shortest paths (Dijkstra, Bellman-Ford), minimum spanning tree (Kruskal, Prim).
- Articulation points and bridges, because CodeVita graph problems frequently involve identifying critical edges or nodes (the Critical Planets problem type in the WP archive is a canonical example).
- Practice 15 to 20 graph problems on Codeforces (Div. 3 and Div. 2 D-level).
Weeks 9 to 12: Dynamic Programming and Advanced Data Structures
- Classic DP: knapsack, longest common subsequence, coin change. The goal is recognising the state space, not memorising code.
- Segment trees and binary indexed trees for range queries. These appear in CodeVita problems where brute-force range operations would time out.
- Practice 10 to 15 DP problems, with a mix of memoization and tabulation approaches.
Weeks 13 to 16: Timed Practice and Contest Simulation
- Attempt two full mock contests per week on Codeforces, HackerEarth, or LeetCode Weekly. Hard time-limit: 3 hours per session.
- After each mock, spend 30 minutes reviewing problems you could not solve, not just the ones you solved.
- In the final week before the actual CodeVita round, review your own implementations of the Sieve, max-heap operations, and BFS/DFS. Running your own code the day before the contest is better than reading someone else’s tutorial.
CodeVita Performance and TCS’s AI-Skilled Hiring in 2026
The skills CodeVita builds (formulating a clean algorithm under unfamiliar constraints, testing edge cases before submission, debugging a wrong answer with limited feedback) are not separate from what TCS currently looks for in its technical hires. According to TCS CHRO Sudeep Kunnumal, 60% of TCS’s FY26 fresher hires are AI-skilled, up from 10 to 15% three years ago. The Prime track, which targets students with the strongest technical profiles, is where AI fluency now plays a direct role.
CodeVita preparation does not make you AI-ready on its own. But the analytical habits it builds, specifically the instinct to define a problem precisely before writing a single line of code, are exactly the habits that make the difference between a developer who uses AI tools reactively and one who directs them deliberately.
If you are working through the 2026 AI roadmap for Indian engineering students, you will find that the LLM layer rewards the same rigour CodeVita demands: clear inputs, well-defined outputs, and systematic testing.
The problems in this article reward students who can debug unfamiliar systems quickly. TinkerLLM is where that same skill applies to LLM APIs: ₹299 puts real API calls in your hands, and working through why a prompt produces the wrong output is the same analytical process as working through why a CodeVita submission fails on hidden test cases. The resulting project is what you put on GitHub before the TCS Prime technical interview.
Primary sources
Frequently asked questions
Is CodeVita the same as TCS NQT?
No. TCS NQT is a campus placement screening test used to shortlist candidates for regular fresher hiring. CodeVita is a global competitive programming contest. High rankers in CodeVita may receive an expedited TCS interview invitation, but the two processes are entirely separate.
Can students from all engineering branches participate in CodeVita?
Yes. CodeVita is open to students of any engineering branch, including CSE, ECE, Mechanical, Civil, and others. Final-year and pre-final-year students are typically eligible. Confirm exact eligibility criteria on the official TCS CodeVita portal for the current season.
What programming languages does CodeVita accept?
CodeVita accepts C, C++, Java, and Python among others. The exact accepted language list varies by season, so check the official portal before registering since language support can change between editions.
How difficult are CodeVita problems compared to LeetCode?
Most CodeVita problems sit between LeetCode Medium and Hard. They require both correct algorithm selection and efficient implementation within a time limit. LeetCode Medium problems often test a single isolated concept; CodeVita problems typically combine two or three concepts within an unfamiliar problem framing.
Does a high CodeVita rank guarantee a TCS job?
No. CodeVita is a contest, not a placement process. Top performers usually receive an invitation for a faster-track interview at TCS. The interview and selection process operates independently of contest rank.
Which data structures appear most often in CodeVita?
Graphs (BFS, DFS, articulation points), heaps (priority queues for greedy problems), and trees (segment trees, binary indexed trees) appear across most CodeVita editions. Contestant post-mortems from recent seasons consistently cite graph traversal and greedy-with-heap as the highest-frequency patterns.
How many rounds does CodeVita have?
CodeVita typically runs three rounds: an open qualification round, a zonal round, and a global final. The format has varied across seasons, so confirm current-season details on the official TCS CodeVita portal before registering.
A self-paced playground for building with LLMs.
TinkerLLM is FACE Prep's sister property. A guided environment for shipping real LLM applications, the kind of project that earns a paragraph on your resume, not a line.
Try TinkerLLM (₹299 launch)