码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • LeetCode每日一题——2586. Count the Number of Vowel Strings in Range


    文章目录

      • 一、题目
      • 二、题解

    一、题目

    You are given a 0-indexed array of string words and two integers left and right.

    A string is called a vowel string if it starts with a vowel character and ends with a vowel character where vowel characters are ‘a’, ‘e’, ‘i’, ‘o’, and ‘u’.

    Return the number of vowel strings words[i] where i belongs to the inclusive range [left, right].

    Example 1:

    Input: words = [“are”,“amy”,“u”], left = 0, right = 2
    Output: 2
    Explanation:

    • “are” is a vowel string because it starts with ‘a’ and ends with ‘e’.
    • “amy” is not a vowel string because it does not end with a vowel.
    • “u” is a vowel string because it starts with ‘u’ and ends with ‘u’.
      The number of vowel strings in the mentioned range is 2.
      Example 2:

    Input: words = [“hey”,“aeo”,“mu”,“ooo”,“artro”], left = 1, right = 4
    Output: 3
    Explanation:

    • “aeo” is a vowel string because it starts with ‘a’ and ends with ‘o’.
    • “mu” is not a vowel string because it does not start with a vowel.
    • “ooo” is a vowel string because it starts with ‘o’ and ends with ‘o’.
    • “artro” is a vowel string because it starts with ‘a’ and ends with ‘o’.
      The number of vowel strings in the mentioned range is 3.

    Constraints:

    1 <= words.length <= 1000
    1 <= words[i].length <= 10
    words[i] consists of only lowercase English letters.
    0 <= left <= right < words.length

    二、题解

    class Solution {
    public:
        int vowelStrings(vector<string>& words, int left, int right) {
            unordered_set<char> set = {'a','e','i','o','u'};
            int res = 0;
            for(int i = left;i <= right;i++){
                char front = words[i][0];
                char back = words[i].back();
                if(set.count(front) && set.count(back)) res++;
            }
            return res;
        }
    };
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
  • 相关阅读:
    使用Python批量发送个性化邮件
    第02章_MySQL的数据目录
    java海城同泽中学图书仓库管理系统计算机毕业设计MyBatis+系统+LW文档+源码+调试部署
    自媒体人必备的热点舆情分析,3个网站
    Vellum|SOP —— Vellum Constraints
    pytorch-softmax回归
    MindSpore自定义算子中的张量维度问题
    android RecyclerView列表自动播放实现
    Vue.js 动画与过渡效果实战
    FastDFS文件上传原理和负载均衡方法
  • 原文地址:https://blog.csdn.net/weixin_46841376/article/details/134260917
  • 最新文章
  • 攻防演习之三天拿下官网站群
    数据安全治理学习——前期安全规划和安全管理体系建设
    企业安全 | 企业内一次钓鱼演练准备过程
    内网渗透测试 | Kerberos协议及其部分攻击手法
    0day的产生 | 不懂代码的"代码审计"
    安装scrcpy-client模块av模块异常,环境问题解决方案
    leetcode hot100【LeetCode 279. 完全平方数】java实现
    OpenWrt下安装Mosquitto
    AnatoMask论文汇总
    【AI日记】24.11.01 LangChain、openai api和github copilot
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1
正则表达式工具 cron表达式工具 密码生成工具

京公网安备 11010502049817号