I am able to understand the concept,but not able to write code ,like I have to genrics or not ?or I have to write the code in which they have provided the template .
I am not able to understand the template of the give code.
And what in case queue ,how to proceed generics or normal.
Doubt in writing code
@Adhyayan,
You have to use Stack data structure in this question. You can use either the stack class inbuilt in Java or you can write your own class StackUsingArray.
The algo would be something like:
Each time you encounter an open bracket simply push it into stack.
If you got any closed bracket.
2.1 If the stack is empty return false.
2.2 Check if the closed bracket matches the peek element of stack.
2.3.1 If yes pop the element and continue.
2.3.2 else return false.
At the end return true if stack is empty.
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.