求最深字符串Output the most inner string

  1. Output the most inner string:  "ab(cd(e)fg)" => "e", "Hello World!" =>"Hello World!" "ab{cd[ef]} gh(hello{hi})" =>"ef", "hi"

先用https://www.geeksforgeeks.org/find-maximum-depth-nested-parenthesis-string/

max和current_max求出最大深度。然后再来一次,最大深度的时候append

 

或者用:https://*.com/questions/12595019/how-to-get-a-string-between-two-characters

一个不需要您执行indexOf的问题的非常有用的解决方案是使用Apache Commons库。

 StringUtils.substringBetween(s, "(", ")");

 

 
上一篇:CF1516A


下一篇:[LeetCode] 1838. Frequency of the Most Frequent Element