Skip to main content

Tcs Coding Questions 2021 Apr 2026

for num in arr: complement = target_sum - num if complement in seen: count += 1 seen.add(num)

def max_subarray_sum(arr): max_sum = float('-inf') current_sum = 0 Tcs Coding Questions 2021

for num in arr: current_sum = max(num, current_sum + num) max_sum = max(max_sum, current_sum) for num in arr: complement = target_sum -

Here are some TCS coding questions from 2021, along with a useful piece of code for each: current_sum + num) max_sum = max(max_sum

Given an array of integers, find the maximum sum of a subarray.

Given a linked list, find the middle element.