您当前的位置: 首页 > 

孑渡

暂无认证

  • 3浏览

    0关注

    178博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

每日一题2021/5/2:砖墙

孑渡 发布时间:2021-06-03 22:34:25 ,浏览量:3

class Solution(object):
    def leastBricks(self, wall):
        """
        :type wall: List[List[int]]
        :rtype: int
        """
        
        max_length = max([sum(wal) for wal in wall])
        route_dict = {}
        height = 0
        max_dict = 0
        for wal in wall:
            height += 1
            temp = 0
            for i in wal:
                temp += i
                if temp != max_length:
                    if route_dict.has_key(temp):
                        route_dict[temp] += 1
                    else:
                        route_dict[temp] = 1
                    if route_dict[temp] > max_dict:
                        max_dict = route_dict[temp]
        return height - max_dict

经验: 水题,但是如果数据规模比较大的话不知道该怎么处理,算法部分没想到更好的方法

关注
打赏
1663211900
查看更多评论
立即登录/注册

微信扫码登录

0.0375s