2023每日刷题(二十二)
Leetcode—2586.统计范围内的元音字符串数
实现代码
class Solution {
public:int vowelStrings(vector<string>& words, int left, int right) {int ans = 0;for(int i = left; i <= right; i++) {string s = words[i];int n = s.size();char head = s[0];char rear = s[n - 1];int flag1 = 0;int flag2 = 0;if(head == 'a' || head == 'e' || head == 'i' || head == 'o' || head == 'u') {flag1 = 1;}if(rear == 'a' || rear == 'e' || rear == 'i' || rear == 'o' || rear == 'u') {flag2 = 1;}if(flag1 && flag2) {ans++;}}return ans;}
};
运行结果
之后我会持续更新,如果喜欢我的文章,请记得一键三连哦,点赞关注收藏,你的每一个赞每一份关注每一次收藏都将是我前进路上的无限动力 !!!↖(▔▽▔)↗感谢支持!