InterviewPrepInterviewPrep· Job Insights

TCS NQT coding practice and submission strategy

The coding section carries real weight in the TCS NQT, and it trips up candidates who can solve on paper but stumble on input handling and time limits. This page covers the problem types TCS favours, how to structure your solve for partial credit, worked examples with clean approaches, and a practice plan that turns logic into fast, working submissions.

Start a free mock interview →

What the coding section looks like

You usually face one or two problems in a language of your choice, with a fixed window per problem. Difficulty spans easy to lower-medium, weighted towards logic and correct input/output rather than advanced algorithms.

  • String manipulation palindromes, reversals, character counts, anagram checks.
  • Array and number logic second largest, frequency counts, sorting-based questions.
  • Pattern and series printing patterns, generating sequences.
  • Basic maths prime checks, factorials, GCD, digit operations.

Crucially, TCS problems often specify exact input and output formats. A logically correct program that reads input wrongly or prints an extra space can fail every test case, so format discipline is half the battle.

Scoring and partial credit strategy

Submissions are graded on hidden test cases, and partial credit for passing some cases usually exists. This shapes the optimal approach: get a correct brute-force solution passing the visible and easy cases first, then optimise only if the constraints demand it and time remains.

A half-finished elegant solution that compiles but handles no edge cases scores worse than a plain loop that passes most cases. Always test your code against the sample input before submitting, and handle the obvious edges, empty input, single element, negative numbers, that graders love to hide in the final test cases.

Because the coding weight is high, clearing this section strongly often matters more than squeezing a few extra aptitude marks.

Worked examples

Second largest in an array: a single pass tracking the largest and second-largest beats sorting and is easy to reason about. Watch the edge case of duplicate maximums, decide whether the second largest must be strictly smaller.

Palindrome check: compare characters from both ends inward. Read the constraints, do you ignore case and spaces? Getting that wrong fails the hidden cases even with perfect logic.

Prime check: loop only up to the square root of n, not to n, so large inputs finish inside the time limit. This is the kind of small optimisation that turns a timeout into full marks.

Frequency count: use a map or fixed-size array; print in the exact order the problem specifies.

How to prepare

Solve one full problem end to end every day for two weeks, writing the input parsing and output formatting yourself rather than copying boilerplate. Rotate through strings, arrays, patterns and basic maths so no category feels unfamiliar. Time each solve; your target is a clean easy problem in well under the section limit so a harder one has room.

Rehearse the submission workflow, not just the algorithm: compile, run against sample, check output character-for-character, then submit. This muscle memory prevents the format slips that quietly cost full sections.

After the online test, TCS interviews probe how you explain your code and projects. InterviewPrep's free AI voice mock interview builds a technical session from your CV and a TCS job description and scores your spoken answers, pace and filler words, so you can talk through your logic confidently in the human round.

Handling input and output cleanly

More TCS coding submissions fail on input/output handling than on flawed logic, so treat parsing as a first-class part of every solve. Read the problem's format specification twice before writing a line: how many inputs, on how many lines, separated by spaces or newlines, and exactly what the output should look like, including whether a trailing newline or specific spacing is expected.

A frequent trap is reading input in the wrong order or type, treating a string as an integer, or missing that the first line gives the array size. Write your input-reading code deliberately and test it against the sample before touching the core logic. If the sample output does not match yours character-for-character, fix the format before assuming your algorithm is wrong.

Edge cases are the second silent killer. Graders routinely hide empty inputs, single elements, negative numbers, zeros, and duplicate values in the final test cases. Before submitting, mentally run your code on these: does a palindrome check handle an empty string, does second-largest handle duplicate maximums, does a prime check reject 0 and 1 correctly?

Finally, submit early and often if the platform allows. Getting a correct brute-force solution in that passes the visible cases banks partial or full credit and takes the pressure off. Only then refine for efficiency. This disciplined loop, parse, test on sample, handle edges, submit, optimise, converts sound logic into the passing test cases that actually earn marks, which is what the coding section rewards.

A cleared coding section on the NQT is often the decisive lift for Freshers Jobs Off Campus Drive rounds in Indian IT, since a strong percentile keeps every subsequent recruiter door open.

Try a few real questions

Sampled from the same bank we use for live placement drives. Answers and explanations unlock in the free practice set.

A 60-litre mixture of milk and water has milk and water in ratio 7 : 3. How much water must be added so that the new ratio becomes 7 : 5?

  • 10 litres
  • 12 litres
  • 15 litres
  • 18 litres

How many factors does the number 360 have?

  • 20
  • 24
  • 18
  • 12

If CAB is coded as XZY, how is DOG coded?

  • WLT
  • WLR
  • VLT
  • WMT

Practise the full set free →

Frequently asked

How many coding questions are in the TCS NQT?
Typically one or two coding problems within the coding section, each with its own time window. Counts vary by drive. Because the section is heavily weighted, fully solving even one problem with all test cases passing can significantly strengthen your overall result.
Which language is best for the TCS coding round?
Use whichever of C, C++, Java or Python you write fastest and most accurately. TCS tests logic and correct input/output, not a specific language, so being fluent with reading input and standard library functions saves crucial time under the clock.
Does the TCS coding section give partial marks?
Usually yes, based on how many hidden test cases your code passes. This makes a working brute-force solution valuable: submit something correct that passes the easy and visible cases first, then optimise for the harder cases only if time allows.
Why does my correct code fail all test cases?
Almost always an input or output format mismatch, an extra space, wrong line breaks, or misreading the input structure. TCS specifies exact formats. Always run your code against the sample input and match the expected output character-for-character before submitting.
How should I practise for the coding round?
Solve one complete problem daily across strings, arrays, patterns and basic maths, writing your own input parsing and timing each solve. Rehearse the full compile-test-submit workflow so format discipline and speed both become automatic on test day.

Related prep

Tcs Nqt Mock Test · Tcs Nqt Aptitude Practice · Tcs Nqt Mock Test · Tcs Nqt Aptitude Practice

Reading about it isn't practice.

Run a real AI mock interview built from your CV and a live job description — scored feedback on your answers, pace and filler words.

Start your free mock interview →