Regular bracket sequences consist of opening and closing brackets of one or more types, with each opening bracket having a closing bracket, and (in the case of multiple types) their types do not overlap.
Correct SP:
( ( ) ) ( ) ( )
{ } [ ( ) ] ( )
{ [ ( { } ) ] }
Invalid SP:
) ) ( ( ) ) ( (
{ [ ( ] ) }
( ( ] }
To check if a bracket sequence of brackets is of the same type, just check the balance.
That is, we start a variable equal to zero (balance). Then we run through the string (if you don't know how to do this - RUN, STUPID!), increasing the balance when it meets the opening bracket and decreasing it when it meets the closing one. If at any stage the balance becomes negative or at the end it is not equal to zero, then the sequence is wrong.