TCS NQT 2025 Coding Questions with Solutions
1. Sum of Integers in a Range
Problem Statement:
Given a range [m, n]
where 0 <= m, n <= 10000
, find the sum of all integers between m
and n
(both inclusive).
Example:
Input:
0 3
Output:
6
Explanation:
0 + 1 + 2 + 3 = 6
Solution (Java):
Solution (Python):
2. Minimum Team Selection to Cover Required Skills
Problem Statement:
Given a list of required skills and a list of candidates, each candidate has a subset of skills. Your goal is to select the smallest possible team such that all required skills are covered.
You are given:
- A list of required skills.
- The number of candidates (
N
). - The skill sets of
N
candidates.
Return the indices of the selected candidates forming the smallest team.
Example:
Input:
Output:
0 2
Solution (Java):
Solution (Python):
3. Find a Unique Element in an Array
Problem Statement:
You are given an array containing N
integers where one element appears exactly once, and all others appear twice. Find and return the unique element.
Example:
Input:
arr = [5, 3, 2, 3, 2]
Output:
5
Solution (Java):
Solution (Python):
4. Make Three Numbers Equal
Problem Statement:
You are given three integers P
, Q
, and R
. You can perform the following operations:
- Select two numbers and increase both by 1.
- Decrease the third number by 1.
Determine the minimum number of operations required to make all three numbers equal.
Example:
Input:
Output:
-1 0 -1 3
Solution (Java):
Solution (Python):