TCS Coding Question 2 Day 1 Slot 1

Coding Question 2 for 2022 (September slot)

In this article, we will discuss about the TCS Coding Question which is asked in the TCS placement test. This type of Coding Questions will help you to crack your upcoming TCS exam as well as during your inteview process.

TCS Coding Question 2 Day1 slot1

TCS Coding Question Day 1 Slot 1 – Question 2

Problem Statement – Given a string S(input consisting) of ‘*’ and ‘#’. The length of the string is variable. The task is to find the minimum number of ‘*’ or ‘#’ to make it a valid string. The string is considered valid if the number of ‘*’ and ‘#’ are equal. The ‘*’ and ‘#’ can be at any position in the string.

Note : The output will be a positive or negative integer based on number of ‘*’ and ‘#’ in the input string.

  • (*>#): positive integer
  • (#>*): negative integer
  • (#=*): 0

Example 1:

Input 1:

  • ###***   -> Value of S

Output :

  • 0 → number of * and # are equal

20 comments on “TCS Coding Question 2 Day 1 Slot 1”