Leetcode 2942. Find Words Containing Character

Problem

You are given a 0-indexed array of strings words and a character x.

Return an array of indices representing the words that contain the character x.

Note that the returned array may be in any order.

Algorithm

Just enumerate and check directly.

Code

python3 复制代码
class Solution:
    def findWordsContaining(self, words: List[str], x: str) -> List[int]:
        ans = []
        for i, word in enumerate(words):
            if x in word:
                ans.append(i)
        
        return ans
相关推荐
阿坤带你走近大数据4 小时前
基金面试准备1
面试·职场和发展
小程故事多_806 小时前
从A2C、TRPO、PPO到GRPO,强化学习策略梯度算法完整演进与大模型落地实战解析
人工智能·算法
2601_956121977 小时前
二分算法(知识点+题目)
c++·算法
AndrewHZ10 小时前
【LLM技术全景】阶段总结:技术原理篇核心知识回顾
人工智能·深度学习·算法·语言模型·大模型·llm·芯片开发
职场的momo11 小时前
五年后端终面被追问方案,技术输出该如何守边界
职场和发展
小星星闪亮登场11 小时前
2026萌新联赛第三场-- (郑州轻工业大学)
数据结构·c++·经验分享·算法·贪心算法·排序算法·深度优先
冻柠檬飞冰走茶11 小时前
PTA基础编程题目集 7-8超速判断(C++语言实现)
开发语言·数据结构·c++·算法
玖玥拾12 小时前
LeetCode 88 合并两个有序数组
算法·leetcode
数据皮皮侠AI12 小时前
上市公司数字供应链金融指数(2010-2024)
大数据·人工智能·算法
小程故事多_8013 小时前
用GRPO算法重塑多智能体系统,从原理落地到复杂任务规划实战
人工智能·算法