码迷,mamicode.com
首页 > 其他好文 > 详细

leetcode-1111

时间:2020-04-02 01:27:08      阅读:78      评论:0      收藏:0      [点我收藏+]

标签:highlight   etc   split   code   UNC   range   ++   end   for   

这道题主要是读题意,但是问题是题意翻译的很差劲,而且这道题并没有唯一期望。

 

至于读懂题意后的代码,就很简单了。

func maxDepthAfterSplit(seq string) []int {
	depth := 0
	var ans []int
	for _, c := range seq {
		if c == ‘(‘ {
			depth++
			ans = append(ans, depth % 2)
		} else {
			ans = append(ans, depth % 2)
			depth--
		}
	}
	return ans
}

  

end

leetcode-1111

标签:highlight   etc   split   code   UNC   range   ++   end   for   

原文地址:https://www.cnblogs.com/CherryTab/p/12616893.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!