SarthakKeshari / CPP-Questions-and-Solutions

This repository aims to solve and create new problems from different spheres of coding. A path to help students to get access to solutions and discuss their doubts.
MIT License
46 stars 132 forks source link

Added Remove Outermost Paranthesis #522

Closed silicolicious closed 2 years ago

silicolicious commented 2 years ago

Choose your form and fill it -

1. Form 1(C++ Solution contributors)


1) Form 1

Issue Id you have worked upon -

Fixes #520

Briefly explain your program logic -

I solved the program using two pointers, one for traversing the string and one for keeping the initial position.
Two variables for counting the opening and closing parenthesis.
When the number of opening and closing parathesis are equal, we found the primitive string and added the content of it to the ans string.

Screenshots(Attach 2 screenshots of your own input and output) -

Attach here image image


Checklist:

All the conditions should be fulfilled for considering your code for merging -