Zheaoli / do-something-right

MIT License
37 stars 3 forks source link

2022-10-29 #405

Open Zheaoli opened 1 year ago

Zheaoli commented 1 year ago

2022-10-29

Dapeus commented 1 year ago

image

dreamhunter2333 commented 1 year ago
#
# @lc app=leetcode.cn id=1773 lang=python3
#
# [1773] 统计匹配检索规则的物品数量
#

from typing import List

# @lc code=start
class Solution:

    rule_map = {"type": 0, "color": 1, "name": 2}

    def countMatches(self, items: List[List[str]], ruleKey: str, ruleValue: str) -> int:
        return sum(
            1
            for item in items
            if item[self.rule_map[ruleKey]] == ruleValue
        )

# @lc code=end

微信id: 而我撑伞 来自 vscode 插件