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)
相关推荐
show433几秒前
多格式导出怎么做?2026免费小程序TXT/SRT实践
开发语言·小程序·c#
岁岁养乐多3 分钟前
LangChain4j 工厂模式
java·开发语言
小小龙学IT12 分钟前
Day 28 项目调试与优化 —— 给聊天室做一次“全面体检“
c语言·开发语言
hy.z_77721 分钟前
【C++】9. Vector
开发语言·c++
Tim_101 小时前
【C++】023、移动语义&深拷贝
开发语言·c++·算法
czhaii1 小时前
word插入表格排版创建或编辑应用技巧
ui·c#·xhtml
ctlover1 小时前
Python模块与包
开发语言·python
雨田言炎1 小时前
十、QThread多线程
linux·服务器·开发语言·前端·qt
djjjx.1 小时前
【 C++ 】stack、queue、优先级队列、仿函数、容器适配器
开发语言·c++
在世修行2 小时前
从零打造 C# 工业视觉检测系统(十一):Task 异步编程与实时性保障
开发语言·c#·task异步