zoukankan      html  css  js  c++  java
  • CF 917A The Monster 【括号匹配】

    【链接】:CF

    Examples
    inputCopy
    ((?))
    outputCopy
    4
    inputCopy
    ??()??
    outputCopy
    7
    
    说明
    For the first sample testcase, the pretty substrings of s s are:
    
    "(?" which can be transformed to "()".
    "?)" which can be transformed to "()".
    "((?)" which can be transformed to "(())".
    "(?))" which can be transformed to "(())".
    For the second sample testcase, the pretty substrings of s s are:
    
    "??" which can be transformed to "()".
    "()".
    "??()" which can be transformed to "()()".
    "?()?" which can be transformed to "(())".
    "??" which can be transformed to "()".
    "()??" which can be transformed to "()()".
    "??()??" which can be transformed to "()()()".
    

    【题意】:
    给你一个字符串只包含'(' 、‘ )’ 、‘ ?’三种字符,?你可以按需求转换成‘(’或’)‘
    定义一个区间为正确的括号序列,当且仅当对该区间进行如下操作之后,该序列为空:每次删除序列中一对相邻的左右括号(),直到删到不能再删
    Input
    一个长度不超过5000的字符串
    Output
    能转换成正确的括号序列的子区间数量
    【分析】:
    【代码】:

  • 相关阅读:
    招行面试
    今日头条面试[教育岗]
    四方精创 面试
    ArrayList 源码
    redis缓存,穿透,击穿,雪崩
    hashMap
    集合整理
    阿里CBU技术部一面
    网安面试
    php递归获取顶级父类id
  • 原文地址:https://www.cnblogs.com/Roni-i/p/9215580.html
Copyright © 2011-2022 走看看