Write a program
that checks the correct parenthesization of several given words
by using a stack of characters.
Input
Input consists of several non-empty words made up only of
‘(’, ‘)’, ‘[’ and ‘]’.
Output
For every word, tell if it is correct or not,
following the format of the example.
About statements
The official statement of a problem is always the one
in the PDF document. The HTML version of the statement
is also given to help you, but may contain some content
that is not well displayed. In case of doubt, always use the PDF.
Public test cases
Input
()[]()
[(])
[](
((())
(([]()[()]))
Output
()[]() is correct
[(]) is incorrect
[]( is incorrect
((()) is incorrect
(([]()[()])) is correct
Input
()[]()
[(])
[](
((())
(([]()[()]))
Output
()[]() is correct
[(]) is incorrect
[]( is incorrect
((()) is incorrect
(([]()[()])) is correct
Input
() [] (()) [
Output
() is correct
[] is correct
(()) is correct
[ is incorrect
Input
() [] (()) [
Output
() is correct
[] is correct
(()) is correct
[ is incorrect