力扣 1773. 统计匹配检索规则的物品数量

解法:hash表

1
2
3
4
5
6
7
def countMatches(items, ruleKey, ruleValue):
ret = 0
keys = {"type": 0, "color": 1, "name": 2}
for item in items:
if item[keys[ruleKey]] == ruleValue:
ret += 1
return ret
  • Copyright: Copyright is owned by the author. For commercial reprints, please contact the author for authorization. For non-commercial reprints, please indicate the source.
  • Copyrights © 2022 eightyninth
  • Visitors: | Views:

请我喝杯咖啡吧~

支付宝
微信