Skip to main content
deleted 18 characters in body
Source Link
Jamal
  • 35.2k
  • 13
  • 134
  • 238

I'm César Cordero. I was testing these algorithms, and it works well, but in some cases, they will fail. I would treat it as a string, using a stack, because it could works for a compiler, and could be more than parenthesisparentheses, brackets and keys.

Test these cases, and if it works in all cases, you are in good waydoing well:

I'm César Cordero. I was testing these algorithms, and it works well, but in some cases, they will fail. I would treat it as a string, using a stack, because it could works for a compiler, and could be more than parenthesis, brackets and keys.

Test these cases, if it works in all cases, you are in good way:

I was testing these algorithms, and it works well, but in some cases, they will fail. I would treat it as a string, using a stack, because it could works for a compiler, and could be more than parentheses, brackets and keys.

Test these cases, and if it works in all cases, you are doing well:

deleted 1 character in body
Source Link

I'm César Cordero. I was testing these algorithms, and it works well, but in some cases, they will fail. I would treat it as a string, not asusing a stack, because it could works for a compiler, and could be more than parenthesis, brackets and keys.

I'm César Cordero. I was testing these algorithms, and it works well, but in some cases, they will fail. I would treat it as a string, not as a stack, because it could works for a compiler, and could be more than parenthesis, brackets and keys.

I'm César Cordero. I was testing these algorithms, and it works well, but in some cases, they will fail. I would treat it as a string, using a stack, because it could works for a compiler, and could be more than parenthesis, brackets and keys.

added 210 characters in body
Source Link
string = "[]{}()[][][]"
print "Should be true"
print str(is_matched(string))

string = "([()][][{}])"
print "Should be true"
print str(is_matched(string))

string = "[(])"
print "Should be false"
print str(is_matched(string))

string = "[([])()({})]"
print "Should be true"
print str(is_matched(string))

string = "[(,,),(,,[])]"
print "Should be true but it fail"fails"
print str(is_matched(string))

string = "[(,,,(,,[])]"
print "Should be false"
print str(is_matched(string))

string = "]"
print "Should be false"
print str(is_matched(string))

string = "["
print "Should be false"
print str(is_matched(string))

string = "{[{}][][({})]}"
print "Should be true"
print str(is_matched(string))

string = """
    public static void main(String args[])
    {
        System.out.println("Hello world");
    }
"""

print "Should be true"
print str(is_matched(string))

string = "[[[((({{{}}})))]]]"
print "Should be true"
print str(is_matched(string))
string = "([()][][{}])"
print "Should be true"
print str(is_matched(string))

string = "[(])"
print "Should be false"
print str(is_matched(string))

string = "[([])()({})]"
print "Should be true"
print str(is_matched(string))

string = "[(,,),(,,[])]"
print "Should be true but it fail"
print str(is_matched(string))

string = "[(,,,(,,[])]"
print "Should be false"
print str(is_matched(string))

string = "]"
print "Should be false"
print str(is_matched(string))

string = "["
print "Should be false"
print str(is_matched(string))

string = "{[{}][][({})]}"
print "Should be true"
print str(is_matched(string))

string = """
    public static void main(String args[])
    {
        System.out.println("Hello world");
    }
"""

print "Should be true"
print str(is_matched(string))
string = "[]{}()[][][]"
print "Should be true"
print str(is_matched(string))

string = "([()][][{}])"
print "Should be true"
print str(is_matched(string))

string = "[(])"
print "Should be false"
print str(is_matched(string))

string = "[([])()({})]"
print "Should be true"
print str(is_matched(string))

string = "[(,,),(,,[])]"
print "Should be true but it fails"
print str(is_matched(string))

string = "[(,,,(,,[])]"
print "Should be false"
print str(is_matched(string))

string = "]"
print "Should be false"
print str(is_matched(string))

string = "["
print "Should be false"
print str(is_matched(string))

string = "{[{}][][({})]}"
print "Should be true"
print str(is_matched(string))

string = """
    public static void main(String args[])
    {
        System.out.println("Hello world");
    }
"""

print "Should be true"
print str(is_matched(string))

string = "[[[((({{{}}})))]]]"
print "Should be true"
print str(is_matched(string))
added 5 characters in body
Source Link
Loading
added 10 characters in body
Source Link
Loading
added 1655 characters in body
Source Link
Loading
Source Link
Loading