当前位置:网站首页>[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

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

边栏推荐
猜你喜欢

Brief discussion -- network security architecture design (V)

Redis Express

On the stability of common sorting

Let's talk about the charm of code language

Talking about -- network security architecture design (4)

Talking about network security architecture design (I)

跳转语句break 和continue

Installation and configuration of MySQL and Navicat

ospf综合实验配置

Keras深度学习实战(15)——从零开始实现YOLO目标检测
随机推荐
牛客刷题系列之初阶版(自守数,返回小于 N 的质数个数,第一个只出现一次的字符)
标准C语言10
医院PACS源码 PACS超声科室源码 DICOM影像工作站源码【源码免费分享】
【Unity项目实践】FSM有限状态机
bs4根据属性索引与名称索引对象
This is a joke
[openvx] VX for basic use of objects_ graph
[unity project practice] FSM finite state machine
Container monitoring three swordsman cadvisor collects monitoring data + influxdb stores data + granfana shows an introduction to chart data
二叉树表达式求值 ~
【WinSock】TCP UDP Boardcast Multicast
浅谈——网路安全架构设计(一)
工控人,你真的了解你的五险一金吗?
Talking about -- network security architecture design (III)
HCIP第十天(初始BGP边界网关协议)
华为再回应“清理34岁以上员工”传言,程序员如何应对“35岁危机”?
[openvx] VX for basic use of objects_ reference
uva1445
【C语言】文件操作
冰冰学习笔记:vim工具的基本操作