What is the problem with this code ? Please help

u are making a fresh stack for each query
declare

    stack<int>s; 

outside while(q)

1 Like

Got it, thank you very much.
can you please give hint to this problem please.
You are given a row of N Bijlibulbs, numbered from 1 to N. You know about each Bijlibulbswhether it’s turned on or off. You can change the state of Bijlibulbs i if Bijlibulb i+1 is turnedon and Bijlibulbs i+2, i+3, … N are turned off. This rule doesn’t apply to lightbulb N, whichcan be switched on or off at will.Compute the minimum number of switches you need to make in order to turn off all theBijlibulbs.

Input Format

The input contains a single string of values from the set {0,1}. N is equal to the length of thestring, and each Bijlibulb is represented by a char. A Bijlibulb that is switched off isrepresented by a 0, and one that is switched on by a 1.

Constraints1 ≤ N ≤ 50.Output Format

The output should contain a single number representing the minimum number of switchesneeded.

Sample Input

1011

Sample Output

13

if this is hackerblock question please provide the link to it ,or simply tell the question name

chhavi ji, this question comes in cast exam which was held on 3rd of may. I don’t have link, please give some hints so that I can solve this question.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

Please help me solve the upper question, give a hint please.

isme yr N kha dia h ?

N to kahi h he nhi

1 Like

The input contains a single string of values from the set {0,1}. N is equal to the length of thestring, and each Bijlibulb is represented by a char. A Bijlibulb that is switched off isrepresented by a 0, and one that is switched on by a 1.
Please read it again

sahi batao to 13 o/p kyu aya vo tk samjh nhi araha
agar vo explain kar sakta h to bta de

Ye hi to mere sath ho raha hai :joy:lol