-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create 23.cpp #54
base: master
Are you sure you want to change the base?
Create 23.cpp #54
Conversation
Use stacks. |
Will it reduce time complexity?How will it make the solution better please elaborate. |
You ever done Infix to Post-fix? We use stacks because they are helpful in expression evaluation. This solution works because there isn't any expression within the braces. But if you use stacks, even if there are any expressions between the braces, you can just count the number of remaining braces after the matching braces have been popped. TL;DR: Solution works, expected solution to use stacks. Some comments in the source code would have been better. 🙂 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Solution works, merge-able. Next time use stacks.
Don't close this PR.
Never used stacks before,i am noobie.Going to google some words now :).
Comment addition noted for next time.
…On Thu, 17 Oct, 2019, 12:08 AM MaDDogx, ***@***.***> wrote:
You ever done Infix to Post-fix? We use stacks because they are helpful in
expression evaluation. This solution works because there isn't any
expression within the braces.
But if you use stacks, even if there are any expressions between the
braces, you can just count the number of remaining braces after the
matching braces have been popped.
TL;DR:
Solution works, expected solution to use stacks.
Some comments in the source code would have been better. 🙂
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#54?email_source=notifications&email_token=AEJ2QZV5ML5J6E2DUD7GBXTQO5NUDA5CNFSM4JBO4TP2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEBNQNZQ#issuecomment-542836454>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEJ2QZXZZEO7IZEALV4NKMTQO5NUDANCNFSM4JBO4TPQ>
.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make some changes, OK?
I'll merge it then.
Next time, stack time.
23.cpp
Outdated
int cases,cases1; | ||
cin>>cases; | ||
cases1=cases; | ||
int ar[cases]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't do this for printing the output.
23.cpp
Outdated
flag+=2; | ||
i++; | ||
} | ||
ar[cases-cases1]=leng-flag; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just print the output using cout
.
int diff = length - flag; // flag? there could have been a better word
cout << diff << "\n;
23.cpp
Outdated
for(int i=0;i<cases;i++) | ||
cout<<ar[i]<<endl; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this, it's not needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
No description provided.