博客
关于我
4.14华为研发岗机试其中一道编程题
阅读量:173 次
发布时间:2019-02-28

本文共 952 字,大约阅读时间需要 3 分钟。

???????????????????????o(???)o???????????????????????????????????????????(??????)?????????????????????????????????????????(?_?)?????????????????????????????????????????????~~o(>_<)o~~?

?????????????????????????????????????????????????????

def circle(s_str):    stack = []    for i in range(len(s_str)):        if s_str[i] == '(':            stack.append(i)    if not s_str or '(' not in s_str:        return s_str    else:        lIndex = stack.pop()        for i in range(lIndex + 1, len(s_str)):            if s_str[i] == ')':                rIndex = i                break        res = s_str[:lIndex] + s_str[rIndex - 1:lIndex:-1] + s_str[rIndex + 1: len(s_str)]        return circle(res)s = input().split()s_str = ''.join(s)print(circle(s_str))

????????????????????????????????????????????????????????????????????????????????????????????????????????????????????

????????????????????????????????????(??????????)??????????????????????????????????????

转载地址:http://nqxn.baihongyu.com/

你可能感兴趣的文章
Objective-C实现first come first served先到先得算法(附完整源码)
查看>>
Objective-C实现Gale-Shapley盖尔-沙普利算法(附完整源码)
查看>>
Objective-C实现hamiltonianCycle哈密尔顿图算法(附完整源码)
查看>>
Objective-C实现hamming numbers汉明数算法(附完整源码)
查看>>
Objective-C实现hanning 窗(附完整源码)
查看>>
Objective-C实现hanoiTower汉诺塔算法(附完整源码)
查看>>
Objective-C实现hardy ramanujana定理算法(附完整源码)
查看>>
Objective-C实现harmonic series调和级数算法(附完整源码)
查看>>
Objective-C实现harris算法(附完整源码)
查看>>
Objective-C实现HashTable哈希表算法(附完整源码)
查看>>
Objective-C实现haversine distance斜距算法(附完整源码)
查看>>
Objective-C实现heap sort堆排序算法(附完整源码)
查看>>
Objective-C实现heap堆算法(附完整源码)
查看>>
Objective-C实现highest response ratio next高响应比优先调度算法(附完整源码)
查看>>
Objective-C实现hill climbing爬山法用来寻找函数的最大值算法(附完整源码)
查看>>
Objective-C实现Hopcroft算法(附完整源码)
查看>>
Objective-C实现hornerMethod霍纳法算法(附完整源码)
查看>>
Objective-C实现Http Post请求(附完整源码)
查看>>
Objective-C实现http下载文件 (附完整源码)
查看>>
Objective-C实现Http协议下载文件(附完整源码)
查看>>