I need to create a static boolean method, boolean isValid(String str) which gets a string and check the brackets in it...
a correct expression is an expression as one of the following:
1) an empty string or a string that includes space only in it.
2) st1 +"" +st2, which st1 and st2 are correct bracket expressions.
3) ("+st+") or ["+st+"] or {"+st+"} which st is a correct bracket expression.
examples:
isValid(" ") == true
isValid("() [] ") == true
isValid("{] [}") == false
Another condition is that the complexity must be linear which says O(0).
Is anyone please can write me a try of that method ?
Thanks !
Adam.