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)
相关推荐
weixin_440730501 小时前
函数return、参数、参数组、递归函数、高阶函数等小结
开发语言·python
sugarzhangnotes2 小时前
【无标题】
开发语言·人工智能·python
geovindu2 小时前
rust: Composite Pattern
开发语言·后端·设计模式·rust·组合模式
samble2 小时前
从零搭建灌装监控系统(十):生产追溯,条码触发自动记录
c#·wpf·mvvm·modbus·工业控制
周杰偷奶茶3 小时前
【Java】数组的定义和使用(附管理系统实战案例)
java·开发语言
橙子圆1234 小时前
JUC之集合类不安全
java·开发语言
阿里嘎多学长4 小时前
2026-09-29 GitHub 热点项目精选
开发语言·程序员·github·代码托管
Bruce_Liuxiaowei4 小时前
网页版 DeepSeek “harness desktop“ WebGL 上下文创建失败排查实录
开发语言·javascript·webgl
狗凯之家源码网4 小时前
PHP 用户反馈系统源码深度评测与实战指南
开发语言·php·用户反馈系统
谢亮_vipxieliang5 小时前
Stream API 不是银弹:常见坑与性能建议
java·开发语言