fork(1) download
  1. #include <stdio.h>
  2.  
  3. r,m;f(char*s){for(r=m=0;*s;r-=*s++==93)r+=*s==91,m=r>m?r:m;return m;}
  4.  
  5. int main(void) {
  6. char string[1000], i;
  7. for(i=0; i<8; i++){
  8. gets(string);
  9. printf("%i\n", f(string));
  10. }
  11. return 0;
  12. }
Success #stdin #stdout 0s 2116KB
stdin
[1]
[1, 2, 3]
[[1, 2, 3]]
[3, [3, [3], 3], 3]
[[[[1], 2], [3, [4]]]]
[1, [[3]], [5, 6], [[[[8]]]], 1]
[1, [[2, 3, [[4], 5], 6, [7, 8]], 9, [10, [[[11]]]], 12, 13], 14]
[[[[[[[3]]]]]]]
stdout
1
1
2
3
4
5
6
7