Problem Description Link
To solve this problem easilly you can use stak.
The pairs of brackets are:
( )
[ ]
{ }
< >
(* *)
The two characters `(*' should be interpreted as one symbol, not as an opening bracket `(' followed immediately by an
asterisk, and similarly for `*)'. The combination `(*)' should be interpreted as `(*' followed by `)'.
Don't forget `(*' counts as one, as does `*)'. The characters that are not brackets also count as one.
Here I gave some inputs and it's outputs
i/p:
(*(*))
((*)
([)]
([ ])()(**)
*)
[
( // 8 space before ' ( '
((**)()a+b)[(a){a+n}])
(*
[(***)]
o/p:
NO 3
NO 3
NO 3
YES
NO 1
NO 2
NO 10
NO 20
NO 2
YES
To solve this problem easilly you can use stak.
The pairs of brackets are:
( )
[ ]
{ }
< >
(* *)
The two characters `(*' should be interpreted as one symbol, not as an opening bracket `(' followed immediately by an
asterisk, and similarly for `*)'. The combination `(*)' should be interpreted as `(*' followed by `)'.
Don't forget `(*' counts as one, as does `*)'. The characters that are not brackets also count as one.
Here I gave some inputs and it's outputs
i/p:
(*(*))
((*)
([)]
([ ])()(**)
*)
[
( // 8 space before ' ( '
((**)()a+b)[(a){a+n}])
(*
[(***)]
o/p:
NO 3
NO 3
NO 3
YES
NO 1
NO 2
NO 10
NO 20
NO 2
YES
No comments:
Post a Comment
Write your comment - Share Knowledge and Experience