当前位置:网站首页>[hero planet July training leetcode problem solving daily] the 22nd day of the orderly gathering

[hero planet July training leetcode problem solving daily] the 22nd day of the orderly gathering

2022-07-23 08:45:00 Seven water Shuliang

[ Hero planet July training LeetCode Problem solving daily ] The first 22 Japan Ordered set

daily

subject

One 、 1418. Order display form

link : 1418. Order display form

1. Title Description

 Insert picture description here

2. Thought analysis

Hard number , The final output should be arranged in order . It's very business .

3. Code implementation

class Solution:
    def displayTable(self, orders: List[List[str]]) -> List[List[str]]:
        tables = sorted(list(set(int(t) for _,t,_ in orders)))
        foods = sorted(list(set(f for _,_,f in orders)))
        cnt = Counter((int(t),f) for _,t,f in orders)
        ans = [
            ['Table'] + foods
        ]
        for t in tables:
            ans.append(
                [str(t)] + [str(cnt[(t,f)]) for f in foods]
            )
        return ans

 Insert picture description here

原网站

版权声明
本文为[Seven water Shuliang]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/204/202207222351148292.html