leetcode554

Posted AsenYang

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了leetcode554相关的知识,希望对你有一定的参考价值。

public class Solution {
    public int LeastBricks(IList<IList<int>> wall) {
        if (wall.Count == 0)
            {
                return 0;
            }
            int count = 0;
            Dictionary<int, int> map = new Dictionary<int, int>();
            foreach (var list in wall)
            {
                int length = 0;
                for (int i = 0; i < list.Count - 1; i++)
                {
                    length += list[i];
                    if (!map.ContainsKey(length))
                    {
                        map.Add(length, 1);
                    }
                    else
                    {
                        map[length]++;
                    }
                    count = Math.Max(count, map[length]);
                }
            }
            return wall.Count - count;
    }
}

https://leetcode.com/problems/brick-wall/#/description

以上是关于leetcode554的主要内容,如果未能解决你的问题,请参考以下文章

[leetcode-554-Brick Wall]

leetcode554

Leetcode 554: Brick Wall

LeetCode554. 砖墙(Java HashMap 统计前缀和)

LeetCode554. 砖墙(Java HashMap 统计前缀和)

LeetCode 554: Brick Wall