@Terence : got it :) :) ...inc/dec wont work
On Thu, Dec 22, 2011 at 10:57 AM, Terence wrote:
> Then what's your output for test case "()(()"?
>
>
> On 2011-12-22 12:45, atul anand wrote:
>
> i guess there is no need of stack , we can take a variable say top;
>
> increment top when open bracket
got it :)
On Thu, Dec 22, 2011 at 10:57 AM, Terence wrote:
> Then what's your output for test case "()(()"?
>
>
> On 2011-12-22 12:45, atul anand wrote:
>
> i guess there is no need of stack , we can take a variable say top;
>
> increment top when open bracket occur "(" and decrement when close
@venky : u call this code???
On Thu, Dec 22, 2011 at 7:44 PM, venky wrote:
> #include#include#define maxsize 100
> struct stack{ int A[maxsize]; int top;}; struct stack s;void
> push(int
> index){ s.top++;if(s.top==maxsize) {
> printf("cannot be pushed"); }
> else{
Then what's your output for test case "()(()"?
On 2011-12-22 12:45, atul anand wrote:
i guess there is no need of stack , we can take a variable say top;
increment top when open bracket occur "(" and decrement when close
bracket ")" occurs.
keep track of first close bracket mismatch i.e when
And I think the comparing between first unmatched open/close bracket
index is not needed.
If we found an unmatched close bracket (ie. the stack is empty when
encounter a close bracket),
we could return current index immediately, since all open brackets
before that position are matched and popp
i guess there is no need of stack , we can take a variable say top;
increment top when open bracket occur "(" and decrement when close bracket
")" occurs.
keep track of first close bracket mismatch i.e when top is zero and current
bracket is ")".
if top!=0
report min(index,top);
On Tue,