摘要: class Solution(object): def isValid(self, s): """ :type s: str :rtype: bool """ left_tag=['(','{','['] right_tag=[')','}',']'] stack_list=[] match_dic 阅读全文
posted @ 2016-10-28 16:26 火金队长 阅读(118) 评论(0) 推荐(0) 编辑
摘要: #遍历所有元素,将元素值当做键、元素下标当做值#存放在一个字典中。遍历的时候,#如果发现重复元素,则比较其下标的差值是否小于k,#如果小于则可直接返回True,否则更新字典中该键的值为新的下标class Solution(object): def containsNearbyDuplicate(se 阅读全文
posted @ 2016-10-28 16:25 火金队长 阅读(337) 评论(0) 推荐(0) 编辑