TCS NQT Part B – Mock Test Paper (Advanced Aptitude + Coding)
Instructions:
- Total Time: 115 minutes
- Section 1: Advanced Quantitative & Reasoning – 16 questions (25 minutes)
- Section 2: Coding – 2 questions (90 minutes)
- Attempt all questions carefully. No negative marking.
Section 1: Advanced Quantitative & Reasoning (16 Questions, 25 min)
- Number Series: Find the next number: 2, 6, 12, 20, 30, ?
- Probability: A box has 5 red, 3 blue, and 2 green balls. What is the probability of picking a red or green ball?
- Time & Work: A can do a job in 12 days, B in 15 days. Working together, how many days will it take to finish?
- Geometry: Find the area of a triangle with base 10 cm and height 8 cm.
- Data Interpretation: The table shows monthly sales of a company over 5 months:
Jan: 120, Feb: 150, Mar: 130, Apr: 140, May: 160
Find the average sales. - Logical Puzzle: Five friends A, B, C, D, and E are sitting in a row. C is not at the end, D is to the left of B. Find the position of X (additional info provided in actual question).
- Ratio & Proportion: Divide 120 in the ratio 3:5:4.
- Permutation & Combination: How many ways can 5 books be arranged on a shelf?
- Syllogism: Statements: All A are B. Some B are C. Which conclusions logically follow?
- Coding Logic (Non-programming): Predict the output of the following pseudo-code:
sum = 0 for i = 1 to 5 sum = sum + i*i print sum - Algebra: Solve for x: 3x + 7 = 25
- Mensuration: Find the volume of a cuboid with length 5 cm, breadth 3 cm, height 2 cm.
- Sequence Puzzle: Fill the blank: 5, 11, 23, 47, ?
- Inequalities: Solve: x/3 + 5 > 9
- Clocks: Find the angle between the hour and minute hand at 3:20
- Advanced Reasoning: Find the missing figure in a 3×3 matrix pattern (diagram-based question)
Section 2: Coding (2 Questions, 90 min)
- Problem Statement 1:
Write a program to find the longest subarray with sum equal to 0.- Input: An integer array
- Output: Length of the longest subarray
- Constraints: 1 ≤ N ≤ 10^5, -10^9 ≤ arr[i] ≤ 10^9
- Problem Statement 2:
Given a string S, find the number of palindromic substrings.- Input: String S (length ≤ 10^4)
- Output: Number of palindromic substrings
- Note: Substrings with different start/end indices are counted separately
TCS NQT Part B – Mock Test Paper Solutions
Section 1: Advanced Quantitative & Reasoning
- Number Series: 2, 6, 12, 20, 30, ?
- Pattern: n² + n: 1²+1=2, 2²+2=6, 3²+3=12, …
- Next: 6²+6 = 42
Answer: 42
- Probability: Red or Green ball = (5+2)/10 = 7/10
Answer: 7/10 - Time & Work:
- A: 1/12 work/day, B: 1/15 work/day
- Together: 1/12 + 1/15 = (5+4)/60 = 9/60 = 3/20 per day
- Days = 1 ÷ (3/20) = 20/3 ≈ 6.67 days
Answer: 6 2/3 days (~6.67 days)
- Geometry (Triangle Area): ½ × base × height = ½ × 10 × 8 = 40 cm²
Answer: 40 cm² - Data Interpretation (Average Sales):
- Total = 120+150+130+140+160 = 700
- Average = 700/5 = 140
Answer: 140
- Logical Puzzle: Depends on the exact conditions; typical logic: identify positions step by step. (For exam: students solve using the clues.)
- Ratio & Proportion: 120 ÷ (3+5+4)=120 ÷ 12 = 10
- Parts: 3×10=30, 5×10=50, 4×10=40
Answer: 30, 50, 40
- Parts: 3×10=30, 5×10=50, 4×10=40
- Permutation & Combination: 5! = 120 ways
Answer: 120 - Syllogism:
- Statements: All A are B. Some B are C.
- Conclusions depend on Venn diagram; generally: “Some A may be C” (cannot be certain).
Answer: Cannot be determined / Only conclusion 2 follows (based on exact statements).
- Coding Logic (Pseudo-code):
- sum = 1²+2²+3²+4²+5² = 1+4+9+16+25 = 55
Answer: 55
- sum = 1²+2²+3²+4²+5² = 1+4+9+16+25 = 55
- Algebra: 3x + 7 = 25 → 3x = 18 → x = 6
Answer: 6 - Mensuration (Cuboid Volume): 5×3×2 = 30 cm³
Answer: 30 cm³ - Sequence Puzzle: 5, 11, 23, 47, ?
- Pattern: multiply by 2 minus 1 → 5×2-1=9 (wait)
Actually: 5→11 (+6), 11→23 (+12), 23→47 (+24) → Pattern: add ×2
Next: 47 + 48 = 95
Answer: 95
- Pattern: multiply by 2 minus 1 → 5×2-1=9 (wait)
- Inequalities: x/3 +5>9 → x/3 >4 → x>12
Answer: x>12 - Clocks (Angle at 3:20):
- Hour hand angle: 330 + 20(0.5) = 90+10=100°
- Minute hand: 20*6=120°
- Angle = |120-100|=20°
Answer: 20°
- Advanced Reasoning (Matrix/Pattern): Solve using rotation, mirror, or sequence rules. Depends on exact diagram.
Section 2: Coding Problems – Hints / Solution Approach
- Longest subarray with sum 0:
- Use hash map / prefix sum approach:
- Keep track of prefix sums; if same sum occurs again, subarray in between has sum 0.
- Time complexity: O(N)
def longest_zero_subarray(arr): prefix_sum = 0 sum_index = {0: -1} max_len = 0 for i, num in enumerate(arr): prefix_sum += num if prefix_sum in sum_index: max_len = max(max_len, i - sum_index[prefix_sum]) else: sum_index[prefix_sum] = i return max_len - Use hash map / prefix sum approach:
- Number of palindromic substrings:
- Use expand around center method or dynamic programming.
- Count all odd and even length palindromes centered at each index.
- Time complexity: O(N²) for length ≤ 10⁴
def count_palindromes(s): n = len(s) count = 0 for center in range(2*n - 1): left = center // 2 right = left + center % 2 while left >= 0 and right < n and s[left] == s[right]: count += 1 left -= 1 right += 1 return count