Tcs Coding Questions 2021 File

Example: Input - [1, 2, 3, 4, 5], target sum - 7, Output - 2

Here are some TCS coding questions from 2021, along with a useful piece of code for each: Tcs Coding Questions 2021

print(first_non_repeating_char("aabbc")) # Output: "c" Example: Input - [1, 2, 3, 4, 5],

Example: Input - "aabbc", Output - "c"

for char in s: if char_count[char] == 1: return char Example: Input - [1

def count_pairs_with_sum(arr, target_sum): count = 0 seen = set()

print(count_pairs_with_sum([1, 2, 3, 4, 5], 7)) # Output: 2