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.
AnswerBot
1y
Find minimum number of * or # to make a string valid with equal number of * and #.
Count the number of * and # in the string.
Find the absolute difference between the counts.
Return the difference as the...read more
PrepInsta
author
2y
#include
using namespace std;
int main()
{
string s;
int a=0,b=0;
getline(cin,s);
for(auto i:s)
if(i=='#') a++;
else if(i=='*') b++;
cout<
Help your peers!
Add answer anonymously...
Top TCS Assistant System Engineer interview questions & answers
Popular interview questions of Assistant System Engineer
Top HR questions asked in TCS Assistant System Engineer
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app
Hello, Guest
COMMUNITIES
REVIEWS
SALARIES
Contribute to help millions!
Write a review
Share interview
Contribute salary
Add office photos
Add office benefits