Parentheses in Codeland

John is a student at Codeland Primary School and he is in trouble with his homework and he needs your help. He tries to check validation of given parentheses. There are three types of opening and closing parentheses which are (, ), {, }, [ and ].

An array of parantheses is provided as the argument str1. If the pairs and the orders of the given parentheses are correct then John should return true otherwise he should return false.

Example Solution

{()}[]{[]} is valid and {[(])} is invalid.

Contributed by Coder