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)
相关推荐
rockey62729 分钟前
C#脚本引擎之AScript与Z.Expressions.Eval对比
c#·.net·script·expression·动态脚本
天下无敌笨笨熊3 小时前
C#Modbus串口开发心得
开发语言·c#
电商API_180079052473 小时前
电商商品价格监控工具淘宝京东商品价格抓取API项目实操分享
java·大数据·开发语言·前端·数据挖掘
zzzll11113 小时前
深度剖析:HashMap 并发死循环与 ConcurrentHashMap 两代演进全解
java·开发语言
如意猴3 小时前
【C++】001--C++入门(1)
开发语言·c++
CSDN_RTKLIB3 小时前
const与readonly关键字
c#
传奇开心果编程4 小时前
【Rust入门知识点学与练】第10课:Option 和 Result(错误处理入门)
开发语言·学习·rust
leonkay4 小时前
C# 锁机制——【2】深入原理
开发语言·后端·spring·c#·个人开发
坐吃山猪4 小时前
【多线程】CompletableFuture使用
java·开发语言·多线程
CHPCWWHSU4 小时前
DeepSeek-Harness-Qt将浏览器端Agent装入桌面应用
开发语言·qt