TCS NQT coding questions 2024

Sahil Ali
3 min readMay 6, 2024

--

So Recently, I took on the TCS NQT exam, and here’s a glimpse into the questions my peers and I grappled with, along with some strategies to crack them:

Photo by MChe Lee on Unsplash

⚠ Important :

Include Input Code: TCS needs not just functions but also code to get input. Your code should handle input from the user or elsewhere like the keyboard. This ensures your code is complete for testing.

Stay Exact with Input/Output: In TCS tests, avoid adding extra info when taking input or showing results. Even a little extra can cause a test to fail. Stick strictly to what’s asked.

  1. Finding the Missing Number:
    Given a sorted array with one number missing, our task was to identify the absent digit.
def find_missing_number(arr):
n = len(arr) + 1
total_sum = n * (n + 1) // 2
arr_sum = sum(arr)
return total_sum - arr_sum

arr = list(map(int, input().split()))
print(find_missing_number(arr))

2. Prime Number Hunt:
We were tasked with finding prime numbers within a given range, where the sum of their digits also had to be prime.

def is_prime(num):
if num <= 1:
return False
for i in range(2, int(num**0.5) + 1):
if num % i == 0:
return False
return True

def digit_sum(num):
return sum(int(digit) for digit in str(num))

def find_prime_numbers(start, end):
prime_numbers = []
for num in range(start, end + 1):
if is_prime(num) and is_prime(digit_sum(num)):
prime_numbers.append(num)
return prime_numbers

# Example usage:
start = int(input("Enter the start of the range: "))
end = int(input("Enter the end of the range: "))
print("Prime numbers with prime digit sum:", find_prime_numbers(start, end))

— — — — — — Another Shift students question — — — — — — — — — — — — —

3. Significant Numbers in an Array: In this problem, we had to identify numbers in an array that appeared more frequently than a certain threshold.

def find_significant_numbers(arr):
threshold = len(arr) // 3
count_map = {}
result = []
for num in arr:
count_map[num] = count_map.get(num, 0) + 1
for num, count in count_map.items():
if count > threshold:
result.append(num)
return result

# Example usage:
arr = list(map(int, input("Enter the array separated by spaces: ").split()))
print("Significant numbers:", find_significant_numbers(arr))

4. Sorting and Grouping: Our challenge here was to sort an array such that identical numbers were grouped together, while maintaining the order of other numbers.

def sort_and_group(arr):
count_map = {}
result = []
for num in arr:
count_map[num] = count_map.get(num, 0) + 1
for num in arr:
if count_map[num] > 0:
result.append(num)
count_map[num] -= 1
return result

arr = list(map(int, input().split()))
print(sort_and_group(arr))

Check out some common tcs question list : https://github.com/SahilAli8808/TCs.git

— — — — — — — — — — — — — — — -One Month Later — — — — — — — — — — — — —
Result: After Exactly one month later a got a mail that I have selected for TCS digital Interview.

Email Screenshot

Tags:
Does TCS ask coding questions?
How many coding questions are there in TCS nqt?
Does TCS nqt questions repeat?
Is TCS digital coding hard?
tcs nqt coding questions pdf
tcs-nqt-coding questions github
tcs nqt coding questions previous year
tcs nqt coding questions 26 april 2024
tcs nqt 2024 aptitude questions
tcs digital coding questions pdf
tcs digital coding questions github

--

--

Sahil Ali

SDE || Exploring New Technologies & Science || Useful Website & AI Tools || Resolving Error | https://www.linkedin.com/in/sahilali20/