2586. 统计范围内的元音字符串数

1.我的思路:枚举范围内的字符串

复制代码
class Solution(object):
    def vowelStrings(self, words, left, right):
        """
        :type words: List[str]
        :type left: int
        :type right: int
        :rtype: int
        """
        count=0
        list=['a','e','i','o','u']
        for word in words[left:right+1]:
            if word[0] in list and word[len(word)-1] in list:
                count=count+1
        return count

2.ai提醒

本质没有变换,但是简化了代码

复制代码
class Solution(object):
    def vowelStrings(self, words, left, right):
        """
        :type words: List[str]
        :type left: int
        :type right: int
        :rtype: int
        """
        count=0
        list1=['a','e','i','o','u']
        result=list(filter(lambda word:word[0] in list1 and word[len(word)-1] in list1, words[left:right+1]))
        return len(result)
相关推荐
czhc11400756631 分钟前
一周概念复盘:预热、漂移与门禁
c#
充值内卷11 分钟前
C++单文件迷宫游戏:TauriCPP 开发全记录
开发语言·c++·游戏
Antruly12 分钟前
C++ Web 开发选型漫谈:从 Drogon 到 libuvcpp + uvp,八个项目的定位、兼容性与务实排名
开发语言·前端·c++
EnCi Zheng16 分钟前
AI Agent工具调用防护层怎么写-一份能直接跑的Python四层拦截实现
大数据·开发语言·python
香蕉大香蕉(06敬畏市场)27 分钟前
高频八股 · Java 并发编程(10):异步、ThreadLocal 与虚拟线程(收官)
java·开发语言·网络·jvm·python·ai·实习
念何架构之路30 分钟前
Go reflect包值操作 Value 的读写、可设置性与 interface 布局
开发语言·后端·golang
云中飞鸿37 分钟前
.Net和C#有什么关系?(从C++视角观察)
开发语言·c#·.net
another heaven38 分钟前
【C/C++ C++ 新特性中的那些内存优化的特性】
c语言·开发语言·c++
Wang's Blog40 分钟前
Java 项目实战: 交友项目 - 查询推荐动态
java·开发语言·交友
jaysee-sjc1 小时前
【苍穹外卖】Day10:定时任务与 WebSocket 实时提醒实战
java·开发语言·javascript·数据库·vue.js·websocket·网络协议