3295. 举报垃圾信息

题目链接 3295. 举报垃圾信息
思路 简单模拟即可
题解链接 哈希集合,简洁写法(Python/Java/C++/Go)
关键点
时间复杂度 O(n)
空间复杂度 O(n)

代码实现:

class Solution:
def reportSpam(self, message: List[str], bannedWords: List[str]) -> bool:
banned = set(bannedWords)
cnt = 0
for item in message:
if item in banned:
cnt += 1
if cnt >= 2:
return True
return False
posted @   WrRan  阅读(8)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 单线程的Redis速度为什么快?
· 展开说说关于C#中ORM框架的用法!
· Pantheons:用 TypeScript 打造主流大模型对话的一站式集成库
· SQL Server 2025 AI相关能力初探
· 为什么 退出登录 或 修改密码 无法使 token 失效
点击右上角即可分享
微信分享提示