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)
相关推荐
牙牙学语的阿猿9 小时前
sentinel创建规则时的坑
java·开发语言·sentinel
超梦dasgg9 小时前
Java 生产环境 JVM 调优实战
java·开发语言·jvm
xyq20249 小时前
HTML DOM 访问
开发语言
WL_Aurora9 小时前
Scala核心编程(二):变量与数据类型详解
开发语言·scala
极地星光9 小时前
源码依赖 vs 预编译二进制包:C/C++ 项目依赖管理决策指南
c语言·开发语言·c++
正运动技术9 小时前
C#运动控制开源(二): CAD导图和小线段速度前瞻优化
c#·正运动技术·运动控制器·运动控制卡·正运动控制器·运动控制开源·ethercat运动控制器
装不满的克莱因瓶9 小时前
【项目亮点四】支付订单超时处理与状态补偿机制设计
java·开发语言·后端·rabbitmq·消息中间件
@Murphy9 小时前
java 面试
java·开发语言·面试
楼田莉子9 小时前
C#学习:分支与循环
服务器·后端·学习·c#