https://codility.com/demo/results/demoU2WQCE-QXU/
Task description A string S consisting of N characters is considered to be properly nested if any of the following conditions is true:
For example, the string "{[()()]}" is properly nested but "([)()]" is not. Write a function:
that, given a string S consisting of N characters, returns 1 if S is properly nested and 0 otherwise. For example, given S = "{[()()]}", the function should return 1 and given S = "([)()]", the function should return 0, as explained above. Assume that:
Complexity:
|
---------------------------------- 풀이 --------------정리전-----------------
Code: 13:04:39 UTC, java, final, score: 100.00
Analysis
Detected time complexity:
O(N)
O(N)
test | time | result | |
---|---|---|---|
Example tests | |||
example1 example test 1 | 1.468 s | OK | |
example2 example test 2 | 1.444 s | OK | |
Correctness tests | |||
negative_match invalid structures | 1.532 s | OK | |
empty empty string | 1.464 s | OK | |
simple_grouped simple grouped positive and negative test, length=22 | 1.344 s | OK | |
Performance tests | |||
large1 simple large positive test, 100K ('s followed by 100K )'s + )( | 0.976 s | OK | |
large2 simple large negative test, 10K+1 ('s followed by 10K )'s + )( + () | 1.340 s | OK | |
large_full_ternary_tree tree of the form T=(TTT) and depth 11, length=177K+ | 1.816 s | OK | |
multiple_full_binary_trees sequence of full trees of the form T=(TT), depths [1..10..1], with/without some brackets at the end, length=49K+ | 1.420 s | OK | |
broad_tree_with_deep_paths string of the form [TTT...T] of 300 T's, each T being '{{{...}}}' nested 200-fold, length=120K+ | 1.444 s | OK |