question_slug
stringlengths 3
77
| title
stringlengths 1
183
| slug
stringlengths 12
45
| summary
stringlengths 1
160
⌀ | author
stringlengths 2
30
| certification
stringclasses 2
values | created_at
stringdate 2013-10-25 17:32:12
2025-04-12 09:38:24
| updated_at
stringdate 2013-10-25 17:32:12
2025-04-12 09:38:24
| hit_count
int64 0
10.6M
| has_video
bool 2
classes | content
stringlengths 4
576k
| upvotes
int64 0
11.5k
| downvotes
int64 0
358
| tags
stringlengths 2
193
| comments
int64 0
2.56k
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
count-the-number-of-vowel-strings-in-range | 💥 Runtime beats 100.00%, Memory beats 75.00% [EXPLAINED] | runtime-beats-10000-memory-beats-7500-ex-2e7a | Intuition\nYou need to count how many strings within a specified range start and end with a vowel.\n\n# Approach\nCreate a Set of Vowels: Use a set to quickly c | r9n | NORMAL | 2024-09-01T11:58:00.912993+00:00 | 2024-09-01T11:59:13.427357+00:00 | 131 | false | # Intuition\nYou need to count how many strings within a specified range start and end with a vowel.\n\n# Approach\nCreate a Set of Vowels: Use a set to quickly check if a character is a vowel.\n\nIterate Through the Range: For each string in the given range, check if it starts and ends with a vowel.\n\nCount Valid Strings: Count strings that meet the vowel condition.\n\n# Complexity\n- Time complexity:\nO(n): You check each string in the specified range, where n is the number of strings in the range.\n\n- Space complexity:\nO(1): The space used is constant, mainly for the vowel set.\n\n# Code\n```rust []\nuse std::collections::HashSet;\n\nimpl Solution {\n pub fn vowel_strings(words: Vec<String>, left: i32, right: i32) -> i32 {\n let vowels: HashSet<_> = [\'a\', \'e\', \'i\', \'o\', \'u\'].iter().copied().collect();\n\n (left as usize..=right as usize)\n .filter(|&i| {\n let word = &words[i];\n let first = word.chars().next().unwrap();\n let last = word.chars().last().unwrap();\n vowels.contains(&first) && vowels.contains(&last)\n })\n .count() as i32\n }\n}\n\n``` | 7 | 0 | ['Rust'] | 0 |
count-the-number-of-vowel-strings-in-range | 0ms (Beats 100%)🔥🔥|| Easy to Understand✅|| O(n)✅|| Java | 0ms-beats-100-easy-to-understand-on-java-6ecw | The Code Explains itself :\n\nclass Solution {\n public int vowelStrings(String[] words, int left, int right) {\n int count = 0;\n for(int i=le | N7_BLACKHAT | NORMAL | 2023-03-30T13:56:13.735072+00:00 | 2023-03-30T13:56:13.735104+00:00 | 903 | false | # The Code Explains itself :\n```\nclass Solution {\n public int vowelStrings(String[] words, int left, int right) {\n int count = 0;\n for(int i=left; i<=right; i++){\n if(check(words[i]))\n count++;\n }\n return count;\n }\n private boolean check(String word){\n char i = word.charAt(0);\n char j = word.charAt(word.length()-1);\n String str = "aeiou";\n if(str.indexOf(i) != -1 && str.indexOf(j) != -1 )\n return true;\n return false;\n }\n}\n```\n**If still someone has doubts ,then Please let me know in Comments** | 7 | 0 | ['Java'] | 0 |
count-the-number-of-vowel-strings-in-range | One Liner | one-liner-by-votrubac-j4b1 | Python 3\npython\nclass Solution:\n def vowelStrings(self, ws: List[str], l: int, r: int) -> int:\n return sum({w[0], w[-1]} < {\'a\', \'e\', \'i\', \ | votrubac | NORMAL | 2023-03-12T04:02:06.620086+00:00 | 2023-03-12T09:37:10.065481+00:00 | 1,560 | false | **Python 3**\n```python\nclass Solution:\n def vowelStrings(self, ws: List[str], l: int, r: int) -> int:\n return sum({w[0], w[-1]} < {\'a\', \'e\', \'i\', \'o\', \'u\'} for w in ws[l:r+1]) \n```\n\n**C++**\n```cpp\nint vowelStrings(vector<string>& ws, int l, int r) { \n return count_if(begin(ws) + l, begin(ws) + r + 1, [](const auto &s){\n auto isVowel = [](char c) { \n return c == \'a\' || c == \'e\' || c == \'i\' || c == \'o\' || c == \'u\';\n };\n return isVowel(s[0]) && isVowel(s.back());\n });\n}\n``` | 7 | 1 | ['Python3'] | 2 |
count-the-number-of-vowel-strings-in-range | JavaScript Code For Beginner 👉 Easy Solution | javascript-code-for-beginner-easy-soluti-m5nq | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | Ugam | NORMAL | 2023-03-12T16:04:53.987500+00:00 | 2023-03-12T16:04:53.987549+00:00 | 410 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n\n\n- Space complexity:\n\n\n# Code\n```\n/**\n * @param {string[]} words\n * @param {number} left\n * @param {number} right\n * @return {number}\n */\nvar vowelStrings = function(words, left, right) {\n const regex = /[aeiou]/;\n let count = 0;\n for (let i = left; i <= right; i++) {\n if (words[i][0].match(regex) && words[i].at(-1).match(regex)) {\n count++;\n }\n }\n return count;\n};\n``` | 6 | 0 | ['JavaScript'] | 0 |
count-the-number-of-vowel-strings-in-range | Image Explanation🏆- [Simplest Solution] | image-explanation-simplest-solution-by-a-fuhs | Video Solution\nhttps://youtu.be/khHg0Zlk7RQ\n\n# Approach & Intuition\n\n\n\n\n# Code\n\nclass Solution {\npublic:\n \n bool isVowel(string& s){\n | aryan_0077 | NORMAL | 2023-03-12T04:19:24.021288+00:00 | 2023-03-12T06:48:17.385730+00:00 | 1,737 | false | # Video Solution\nhttps://youtu.be/khHg0Zlk7RQ\n\n# Approach & Intuition\n\n\n\n\n# Code\n```\nclass Solution {\npublic:\n \n bool isVowel(string& s){\n int n = s.length();\n if( (s[0] == \'a\' || s[0] == \'e\' || s[0]==\'i\' || s[0]==\'o\' || s[0] == \'u\') && (s[n-1] == \'a\' || s[n-1] == \'e\' || s[n-1]==\'i\' || s[n-1]==\'o\' || s[n-1] == \'u\')) return true;\n return false;\n }\n \n int vowelStrings(vector<string>& words, int left, int right) {\n int ans = 0;\n for(int i=left;i<=right;i++){\n if(isVowel(words[i]))\n ans++;\n }\n \n return ans;\n }\n};\n``` | 6 | 2 | ['C++'] | 1 |
count-the-number-of-vowel-strings-in-range | 100% FASTER|| JAVA|| SHORT CODE, VERY EASY TO UNDERSTAND | 100-faster-java-short-code-very-easy-to-maft1 | please UPVOTE it, if you like it\n\n\n# Complexity\n- Time complexity:O(N)\n\n- Space complexity:O(1)\n\n\n# Code\n\nclass Solution {\n public int vowelStrin | sharforaz_rahman | NORMAL | 2023-03-22T17:39:25.274204+00:00 | 2023-03-22T18:43:51.413260+00:00 | 638 | false | **please UPVOTE it, if you like it**\n\n\n# Complexity\n- Time complexity:O(N)\n\n- Space complexity:O(1)\n\n\n# Code\n```\nclass Solution {\n public int vowelStrings(String[] words, int left, int right) {\n int count = 0;\n for (int i = left; i <= right; i++) {\n if (checkingWord(words[i])) count++;\n }\n return count;\n }\n\n public static boolean checkingWord(String s) {\n return checkVowel(s.charAt(0)) && checkVowel(s.charAt(s.length() - 1));\n }\n\n public static boolean checkVowel(char c) {\n return c == \'a\' || c == \'e\' || c == \'i\' || c == \'o\' || c == \'u\';\n }\n}\n``` | 5 | 0 | ['Java'] | 0 |
count-the-number-of-vowel-strings-in-range | Easy 3lines solution in python || Run time 100% memory 100%🔥🔥🔥 | easy-3lines-solution-in-python-run-time-5vxv8 | \n\n# Code\n\nclass Solution(object):\n def vowelStrings(self, words, left, right):\n """\n :type words: List[str]\n :type left: int\n | Lalithkiran | NORMAL | 2023-03-13T10:00:12.052451+00:00 | 2023-03-13T10:00:12.052494+00:00 | 1,229 | false | \n\n# Code\n```\nclass Solution(object):\n def vowelStrings(self, words, left, right):\n """\n :type words: List[str]\n :type left: int\n :type right: int\n :rtype: int\n """\n s="aeiou"\n cnt=0\n for i in range(left,right+1):\n if words[i][0] in s and words[i][-1] in s:cnt+=1\n return cnt\n``` | 5 | 0 | ['Python'] | 0 |
count-the-number-of-vowel-strings-in-range | Simple c++ solution | simple-c-solution-by-aniketrajput25-b7p1 | Intuition\nConstraints are low here so we can just traverse through the vector in the given range.\n\n# Approach\n Describe your approach to solving the problem | aniketrajput25 | NORMAL | 2023-03-12T06:14:19.618585+00:00 | 2023-03-12T06:14:19.618625+00:00 | 534 | false | # Intuition\nConstraints are low here so we can just traverse through the vector in the given range.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1. Initialise ans with 0.\n2. Start loop at left till right and check if front and back of string are vowel letter or not.If they are vowel then just increase count of ans by 1.\n3.Return the ans.\n\n# Complexity\n- Time complexity: O(N)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n bool check(char s)\n {\n return (s==\'a\' || s==\'e\'|| s==\'o\'|| s==\'i\' || s==\'u\');\n }\n int vowelStrings(vector<string>& words, int left, int right) {\n int ans=0;\n for(int i=left;i<=right;i++)\n {\n if(check(words[i].front()) && check(words[i].back())) ans++;\n }\n return ans;\n }\n};\n``` | 5 | 0 | ['Counting', 'C++'] | 0 |
count-the-number-of-vowel-strings-in-range | ✅ FAST solution | fast-solution-by-coding_menance-v0cv | Code\nC++ []\nclass Solution {\npublic:\n bool isvowel(char &ch){\n return ch == \'a\' || ch == \'e\' || ch==\'i\' ||\n ch == \'o\' || c | coding_menance | NORMAL | 2023-03-12T04:28:54.770816+00:00 | 2023-03-12T04:37:19.865463+00:00 | 1,255 | false | # Code\n``` C++ []\nclass Solution {\npublic:\n bool isvowel(char &ch){\n return ch == \'a\' || ch == \'e\' || ch==\'i\' ||\n ch == \'o\' || ch == \'u\';\n }\n \n int vowelStrings(vector<string>& words, int left, int right) {\n int cnt=0;\n \n for(int i=left; i<=right; i++){\n int n=words[i].length();\n \n if(isvowel(words[i][0]) && isvowel(words[i][n-1])) cnt++;\n }\n \n return cnt;\n }\n};\n``` | 5 | 0 | ['C++'] | 0 |
count-the-number-of-vowel-strings-in-range | C++ || Easy | c-easy-by-shrikanta8-2qda | \n# Code\n\nclass Solution {\npublic:\n int vowelStrings(vector<string>& words, int left, int right) {\n\n int ans=0;\n string str="aeiou";\n | Shrikanta8 | NORMAL | 2023-03-12T04:17:14.144338+00:00 | 2023-03-12T04:17:14.144369+00:00 | 1,306 | false | \n# Code\n```\nclass Solution {\npublic:\n int vowelStrings(vector<string>& words, int left, int right) {\n\n int ans=0;\n string str="aeiou";\n for(int i=left;i<=right;i++){\n\n char f=words[i][0], s = words[i][words[i].length()-1];\n if( (str.find(f) != string::npos) && (str.find(s) != string::npos) )\n ans++;\n }\n return ans;\n }\n};\n``` | 5 | 0 | ['C++'] | 0 |
count-the-number-of-vowel-strings-in-range | Simple solution - Daily challenge | simple-solution-daily-challenge-by-dixon-8s3c | \n# Code\njava []\nclass Solution {\n public int vowelStrings(String[] words, int left, int right) {\n\n HashSet<Character> hs = new HashSet<>();\n | Dixon_N | NORMAL | 2024-09-26T00:08:37.043235+00:00 | 2024-09-26T00:08:37.043264+00:00 | 192 | false | \n# Code\n```java []\nclass Solution {\n public int vowelStrings(String[] words, int left, int right) {\n\n HashSet<Character> hs = new HashSet<>();\n hs.add(\'a\');hs.add(\'e\');hs.add(\'i\');hs.add(\'o\');hs.add(\'u\');\n \n int count =0;\n for(int i=left;i<=right && i<words.length;i++){\n\n if(hs.contains(words[i].charAt(0)) && hs.contains(words[i].charAt(words[i].length()-1))){\n count++;\n }\n }\n return count;\n \n }\n}\n```\n```jaav []\n// Faster\n\nclass Solution {\n \n public int vowelStrings(String[] words, int left, int right) {\n int count = 0;\n for (int i = left; i <= right; ++i) {\n // Check if the first and last characters of the word are vowels\n if (isVowel(words[i].charAt(0)) && isVowel(words[i].charAt(words[i].length() - 1))) {\n count++;\n }\n }\n return count;\n }\n\n // Helper method to check if a character is a vowel\n public boolean isVowel(char w) {\n return (w == \'a\' || w == \'e\' || w == \'i\' || w == \'o\' || w == \'u\');\n }\n}\n\n``` | 4 | 0 | ['Java'] | 3 |
count-the-number-of-vowel-strings-in-range | ✅Easy Java solution||Beginner Friendly🔥||HashSet | easy-java-solutionbeginner-friendlyhashs-kf3n | If you really found my solution helpful please upvote it, as it motivates me to post such kind of codes and help the coding community, if you have some queries | deepVashisth | NORMAL | 2023-03-13T18:07:54.593334+00:00 | 2023-03-13T18:13:30.369677+00:00 | 192 | false | **If you really found my solution helpful please upvote it, as it motivates me to post such kind of codes and help the coding community, if you have some queries or some improvements please feel free to comment and share your views.**\n# Code\n```\nclass Solution {\n public int vowelStrings(String[] words, int left, int right) {\n HashSet<Character> set = new HashSet<Character>();\n set.add(\'a\');\n set.add(\'e\');\n set.add(\'i\');\n set.add(\'o\');\n set.add(\'u\');\n \n int count = 0;\n for(int i = left; i <= right; i ++){\n if(set.contains(words[i].charAt(0)) && set.contains(words[i].charAt(words[i].length()-1))){\n count++;\n }\n }\n return count;\n }\n}\n```\n\n | 4 | 0 | ['Hash Table', 'Java'] | 1 |
count-the-number-of-vowel-strings-in-range | JavaScript - JS | javascript-js-by-mlienhart-di8k | \n/**\n * @param {string[]} words\n * @param {number} left\n * @param {number} right\n * @return {number}\n */\nvar vowelStrings = function (words, left, right) | mlienhart | NORMAL | 2023-03-12T08:32:07.167044+00:00 | 2023-03-12T08:32:07.167087+00:00 | 297 | false | ```\n/**\n * @param {string[]} words\n * @param {number} left\n * @param {number} right\n * @return {number}\n */\nvar vowelStrings = function (words, left, right) {\n let result = 0;\n const vowels = ["a", "e", "i", "o", "u"];\n\n for (let i = left; i <= right; i++) {\n if (\n vowels.includes(words[i][0]) &&\n vowels.includes(words[i][words[i].length - 1])\n ) {\n result++;\n }\n }\n\n return result;\n};\n``` | 4 | 0 | ['JavaScript'] | 0 |
count-the-number-of-vowel-strings-in-range | ✅C++ || Beginner Friendly && Straight Forward || CLEAN CODE | c-beginner-friendly-straight-forward-cle-uhdi | \n\nT->O(r-l) && S->O(1)\n\n\tclass Solution {\n\t\tpublic:\n\t\t\tint vowelStrings(vector& w, int l, int r) {\n\t\t\t\tint ans = 0;\n\t\t\t\tfor(int i = l; i < | abhinav_0107 | NORMAL | 2023-03-12T04:05:16.315173+00:00 | 2023-03-12T04:05:16.315204+00:00 | 958 | false | \n\n**T->O(r-l) && S->O(1)**\n\n\tclass Solution {\n\t\tpublic:\n\t\t\tint vowelStrings(vector<string>& w, int l, int r) {\n\t\t\t\tint ans = 0;\n\t\t\t\tfor(int i = l; i <= r ; i++){\n\t\t\t\t\tif((w[i].front() ==\'a\' || w[i].front() == \'e\' || w[i].front() == \'i\' || w[i].front() == \'o\' || w[i].front() == \'u\') && (w[i].back() == \'a\' || w[i].back() == \'e\' || w[i].back() == \'i\' || w[i].back() == \'o\' || w[i].back() == \'u\') ) ans++;\n\t\t\t\t}\n\t\t\t\treturn ans;\n\t\t\t}\n\t\t}; | 4 | 0 | ['C', 'C++'] | 0 |
count-the-number-of-vowel-strings-in-range | Simple Python Solution | simple-python-solution-by-krush_r_sonwan-nlue | Complexity\nTime O(r - l + 1)\nSpace O(1)\n\n# Code\n\nclass Solution(object):\n def vowelStrings(self, words, l, r):\n res = 0\n for i in rang | krush_r_sonwane | NORMAL | 2023-03-12T04:03:36.383759+00:00 | 2023-03-12T04:03:36.383802+00:00 | 441 | false | # Complexity\nTime `O(r - l + 1)`\nSpace `O(1)`\n\n# Code\n```\nclass Solution(object):\n def vowelStrings(self, words, l, r):\n res = 0\n for i in range(l, r + 1):\n if words[i][-1] in \'aeiuo\' and words[i][0] in \'aeiou\': \n res += 1\n return res\n``` | 4 | 0 | ['Python'] | 0 |
count-the-number-of-vowel-strings-in-range | ✅ c++ simple string solution ✅ | c-simple-string-solution-by-suraj_jha989-p0hp | \n# Code\n\nclass Solution {\npublic:\n /* app 1: \n algo ::\n \n for each word in string array starting from left to right.\n check if it starts | suraj_jha989 | NORMAL | 2023-03-12T04:02:38.514341+00:00 | 2023-03-12T04:02:38.514372+00:00 | 480 | false | \n# Code\n```\nclass Solution {\npublic:\n /* app 1: \n algo ::\n \n for each word in string array starting from left to right.\n check if it starts and ends with vowel or not.\n and maintain a count.\n return the count.\n \n */\n \n //fun to check vowels\n bool isvowel(char &ch){\n return ch == \'a\' || ch == \'e\' || ch==\'i\' ||\n ch == \'o\' || ch == \'u\';\n }\n \n int vowelStrings(vector<string>& words, int left, int right) {\n int cnt=0;\n \n for(int i=left; i<=right; i++){\n //cur word\n string w = words[i];\n int n=w.size();\n \n //if cur word st. and ends with vowel\n if(isvowel(w[0]) && isvowel(w[n-1])) cnt++;\n }\n \n return cnt;\n }\n};\n``` | 4 | 0 | ['C++'] | 1 |
count-the-number-of-vowel-strings-in-range | Easy Java Solution | easy-java-solution-by-1asthakhushi1-8l09 | \n# Code\n\nclass Solution {\n public int vowelStrings(String[] words, int left, int right) {\n HashSet<Character> hs=new HashSet<>();\n hs.add | 1asthakhushi1 | NORMAL | 2023-03-12T04:01:11.832320+00:00 | 2024-02-27T06:27:31.849013+00:00 | 346 | false | \n# Code\n```\nclass Solution {\n public int vowelStrings(String[] words, int left, int right) {\n HashSet<Character> hs=new HashSet<>();\n hs.add(\'a\');\n hs.add(\'e\');\n hs.add(\'i\');\n hs.add(\'o\');\n hs.add(\'u\');\n int count=0;\n for(int i=left;i<=right;i++){\n String s=words[i];\n char ch1=s.charAt(0);\n char ch2=s.charAt(s.length()-1);\n if(hs.contains(ch1) && hs.contains(ch2))\n count++;\n }\n return count;\n }\n}\n``` | 4 | 0 | ['Ordered Set', 'Java'] | 0 |
count-the-number-of-vowel-strings-in-range | count-the-number-of-vowel-strings-in-range👌 🏆O(N)❤️ Javascript❤️ Memory👀59.03%🕕 Meaningful Vars | count-the-number-of-vowel-strings-in-ran-55at | \nconst vowels = { a: true, e: true, i: true, o: true, u: true };\n\nvar vowelStrings = function (words, left, right) {\n let count = 0\n for (let index = | anurag-sindhu | NORMAL | 2023-09-12T09:48:27.157136+00:00 | 2023-09-12T09:48:27.157157+00:00 | 119 | false | ```\nconst vowels = { a: true, e: true, i: true, o: true, u: true };\n\nvar vowelStrings = function (words, left, right) {\n let count = 0\n for (let index = left; index <= right; index++) {\n if (vowels[words[index][0]] && vowels[words[index][words[index].length - 1]]) {\n count++\n } else {\n if (!index) {\n words[index] = 0;\n } else {\n words[index] = words[index - 1];\n }\n }\n }\n return count;\n};\n\n``` | 3 | 0 | ['JavaScript'] | 1 |
count-the-number-of-vowel-strings-in-range | ||Easy Java Solution|| | easy-java-solution-by-ammar_saquib-q6f9 | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | ammar_saquib | NORMAL | 2023-07-22T20:13:36.895668+00:00 | 2023-07-22T20:13:36.895692+00:00 | 20 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n public int vowelStrings(String[] words, int left, int right) {\n int count=0;\n for(int i=left;i<=right;i++){\n char c=words[i].charAt(0);\n char d=words[i].charAt(words[i].length()-1);\n if((c==\'a\' || c==\'e\' || c==\'i\' || c==\'o\' || c==\'u\' )&& (d==\'a\' || d==\'e\' || d==\'i\' || d==\'o\' || d==\'u\')){\n count++;\n }\n }\n return count;\n }\n}\n``` | 3 | 0 | ['Java'] | 0 |
count-the-number-of-vowel-strings-in-range | C++ || VERY SIMPLE | c-very-simple-by-ganeshkumawat8740-yev6 | Code\n\nclass Solution {\npublic:\n int vowelStrings(vector<string>& words, int left, int right) {\n int x = 0;\n for(int i = left ; i<= right; | ganeshkumawat8740 | NORMAL | 2023-05-15T12:52:43.251303+00:00 | 2023-05-15T12:52:43.251344+00:00 | 808 | false | # Code\n```\nclass Solution {\npublic:\n int vowelStrings(vector<string>& words, int left, int right) {\n int x = 0;\n for(int i = left ; i<= right; i++){\n if((words[i][0]==\'a\'||words[i][0]==\'e\'||words[i][0]==\'i\'||words[i][0]==\'o\'||words[i][0]==\'u\')&&((words[i][words[i].length()-1]==\'a\'||words[i][words[i].length()-1]==\'e\'||words[i][words[i].length()-1]==\'i\'||words[i][words[i].length()-1]==\'o\'||words[i][words[i].length()-1]==\'u\'))){\n x++;\n }\n }\n return x;\n }\n};\n``` | 3 | 0 | ['C++'] | 0 |
count-the-number-of-vowel-strings-in-range | Python | Easy Solution✅ | python-easy-solution-by-gmanayath-mjgz | Code\n\nclass Solution:\n def vowelStrings(self, words: List[str], left: int, right: int) -> int:\n output= 0 \n vowel = {\'a\',\'e\',\'i\',\'o | gmanayath | NORMAL | 2023-03-15T05:02:49.134614+00:00 | 2023-03-15T05:02:49.134653+00:00 | 218 | false | # Code\n```\nclass Solution:\n def vowelStrings(self, words: List[str], left: int, right: int) -> int:\n output= 0 \n vowel = {\'a\',\'e\',\'i\',\'o\',\'u\'}\n for i in range(left,right+1):\n if words[i][0] in vowel and words[i][-1] in vowel:\n output +=1\n return output\n``` | 3 | 0 | ['Array', 'Python', 'Python3'] | 0 |
count-the-number-of-vowel-strings-in-range | 8 LINE EASY UNDERSTAND C++ CODE | 8-line-easy-understand-c-code-by-yash___-42c2 | \nint vowelStrings(vector<string>& words, int left, int right) {\n int ans = 0;\n unordered_set<char> s = {\'a\',\'e\',\'i\',\'o\',\'u\'};\n | yash___sharma_ | NORMAL | 2023-03-13T15:59:14.297362+00:00 | 2023-03-13T15:59:14.297408+00:00 | 644 | false | ```\nint vowelStrings(vector<string>& words, int left, int right) {\n int ans = 0;\n unordered_set<char> s = {\'a\',\'e\',\'i\',\'o\',\'u\'};\n for(int i = left; i<= right; i++){\n ans += (s.count(words[i][0]) && s.count(words[i][words[i].length()-1]));\n }\n return ans;\n }\n\t``` | 3 | 0 | ['Array', 'String', 'C', 'Ordered Set', 'C++'] | 0 |
count-the-number-of-vowel-strings-in-range | Fastest java solution | fastest-java-solution-by-codehunter01-gj3l | \n\nclass Solution {\n public int vowelStrings(String[] words, int left, int right) {\n int count=0;\n for(int i=left;i<=right;i++)\n {\ | codeHunter01 | NORMAL | 2023-03-12T04:31:50.879471+00:00 | 2023-03-12T04:31:50.879499+00:00 | 69 | false | \n```\nclass Solution {\n public int vowelStrings(String[] words, int left, int right) {\n int count=0;\n for(int i=left;i<=right;i++)\n {\n String s = words[i];\n int n = s.length()-1;\n if((s.charAt(0)==\'a\'||s.charAt(0)==\'e\'||s.charAt(0)==\'i\'||s.charAt(0)==\'o\'||s.charAt(0)==\'u\') && (s.charAt(n)==\'a\'||s.charAt(n)==\'e\'||s.charAt(n)==\'i\'||s.charAt(n)==\'o\'||s.charAt(n)==\'u\'))\n count++;\n \n \n }\n return count;\n }\n}\n``` | 3 | 0 | ['Java'] | 2 |
count-the-number-of-vowel-strings-in-range | Java | Simple | Beats 100% | java-simple-beats-100-by-judgementdey-u660 | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | judgementdey | NORMAL | 2023-03-12T04:02:51.180492+00:00 | 2023-03-12T04:02:51.180528+00:00 | 43 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n private boolean isVowel(char c) {\n return c == \'a\' || c == \'e\' || c == \'i\' || c == \'o\' || c == \'u\';\n }\n \n public int vowelStrings(String[] words, int left, int right) {\n var cnt = 0;\n \n for (var i = left; i <= right; i++)\n if (isVowel(words[i].charAt(0)) && isVowel(words[i].charAt(words[i].length() - 1)))\n cnt++;\n \n return cnt;\n }\n}\n``` | 3 | 0 | ['Java'] | 0 |
count-the-number-of-vowel-strings-in-range | LeetCode 2586 - Beats 100% of other submissions - Fanoob | leetcode-2586-beats-100-of-other-submiss-wa2w | BEATS 100% OF SOLUTIONS!! FANOOB CERTIFIED!Complexity
Time complexity: O(n)
Space complexity: O(1)
Code | SuperbYellowCat | NORMAL | 2025-04-08T06:50:54.872476+00:00 | 2025-04-08T06:50:54.872476+00:00 | 17 | false | BEATS 100% OF SOLUTIONS!! FANOOB CERTIFIED!
# Complexity
- Time complexity: O(n)
- Space complexity: O(1)
# Code
```java []
class Solution {
public int vowelStrings(String[] words, int left, int right) {
int ans = 0;
for(int i = left; i <= right; i++){
if("aeiou".indexOf(words[i].charAt(0)) >= 0 && "aeiou".indexOf(words[i].charAt(words[i].length() - 1)) >= 0) ans++;
}
return ans;
}
}
``` | 2 | 0 | ['Java'] | 0 |
count-the-number-of-vowel-strings-in-range | leetcodedaybyday - Beats 100% with C++ - 41.36% with Python3 - 6.29% with Java | leetcodedaybyday-beats-100-with-c-4136-w-cycn | IntuitionThe problem requires us to count words that start and end with a vowel within a given range [left, right]. A vowel is defined as one of {'a', 'e', 'i', | tuanlong1106 | NORMAL | 2025-02-28T08:58:40.680142+00:00 | 2025-02-28T08:58:40.680142+00:00 | 170 | false | # **Intuition**
The problem requires us to count words that start and end with a vowel within a given range `[left, right]`. A vowel is defined as one of `{'a', 'e', 'i', 'o', 'u'}`.
# **Approach**
1. **Use a vowel set:** Store the vowels in a set for quick lookup.
2. **Iterate through the range:** Loop through `words` from index `left` to `right`.
3. **Check first and last characters:** If both the first and last characters of a word are vowels, increment the count.
# **Complexity**
- **Time Complexity:** \(O(n)\) – We iterate through at most `n` words in the given range.
- **Space Complexity:** \(O(1)\) – Only a set of vowels and a counter variable are used.
---
# Code
```cpp []
class Solution {
public:
int vowelStrings(vector<string>& words, int left, int right) {
unordered_set<char> vowels = {'a', 'e', 'u', 'i', 'o'};
int count = 0;
for (int i = left; i <= right; i++){
string word = words[i];
if (vowels.count(word.front()) && vowels.count(word.back())){
count++;
}
}
return count;
}
};
```
```java []
class Solution {
public int vowelStrings(String[] words, int left, int right) {
Set<Character> vowels = new HashSet<>(Arrays.asList('a', 'e', 'i', 'u', 'o'));
int count = 0;
for (int i = left; i <= right; i++){
String word = words[i];
if (vowels.contains(word.charAt(0)) && vowels.contains(word.charAt(word.length() - 1))){
count++;
}
}
return count;
}
}
```
```python3 []
class Solution:
def vowelStrings(self, words: List[str], left: int, right: int) -> int:
char = 0
vowel = "aeiou"
for i in range(left, right + 1):
if words[i][0] in vowel and words[i][-1] in vowel:
char += 1
return char
```
| 2 | 0 | ['Array', 'String', 'C++', 'Java', 'Python3'] | 0 |
count-the-number-of-vowel-strings-in-range | Simple 2 lines java code | simple-2-lines-java-code-by-arshi_bansal-77jm | Complexity
Time complexity: O(n)
Space complexity: O(1)
Code | arshi_bansal | NORMAL | 2025-01-13T18:42:56.486884+00:00 | 2025-01-13T18:42:56.486884+00:00 | 315 | false | # Complexity
- Time complexity: O(n)
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity: O(1)
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
# Code
```java []
class Solution {
public int vowelStrings(String[] words, int left, int right) {
int count=0;
String vowels = "aeiou";
for(int i=left;i<=right;i++){
String word = words[i];
if(vowels.indexOf(word.charAt(0))!=-1&&vowels.indexOf(word.charAt(word.length() - 1)) != -1) {
count++;
}
}
return count;
}
}
``` | 2 | 0 | ['Java'] | 0 |
count-the-number-of-vowel-strings-in-range | Simple JS solution | simple-js-solution-by-midhunambadan-kz4q | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | midhunambadan | NORMAL | 2024-10-28T08:22:54.624281+00:00 | 2024-10-28T08:22:54.624305+00:00 | 40 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```javascript []\n/**\n * @param {string[]} words\n * @param {number} left\n * @param {number} right\n * @return {number}\n */\nvar vowelStrings = function (words, left, right) {\n let count = 0\n let vowels = [\'a\', \'e\', \'i\', \'o\', \'u\']\n for (let i = left; i <= right; i++) {\n let word = words[i]\n let first = word[0]\n let last = word[word.length - 1]\n if (vowels.includes(first) && vowels.includes(last)) {\n count++\n }\n\n }\n return count\n};\n``` | 2 | 0 | ['JavaScript'] | 2 |
count-the-number-of-vowel-strings-in-range | Easy Java Solution | easy-java-solution-by-umangshakya03-de6w | Intuition\n Describe your first thoughts on how to solve this problem. \nThe problem appears to involve counting the number of words in a given range that begin | umangshakya03 | NORMAL | 2024-01-14T17:51:03.972022+00:00 | 2024-01-14T17:51:03.972049+00:00 | 285 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe problem appears to involve counting the number of words in a given range that begin and end with a vowel.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nThe provided code defines a method, vowelStrings, that iterates through the words in the specified range (left to right). For each word, it checks if both the first and last characters are vowels using the isVowel method. If both conditions are met, it increments the count. The result is the count of words that fulfill the specified criteria.\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nThe code iterates through the words in the specified range once, resulting in a time complexity of O(n), where n = number of words in the range. \n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n The code uses a constant amount of additional space, resulting in O(1) space complexity.\n\n# Code\n```\nclass Solution {\n public int vowelStrings(String[] words, int left, int right) {\n int count=0;\n for(int i=left;i<=right;i++){\n if(isVowel(words[i].charAt(0)) && isVowel(words[i].charAt(words[i].length()-1))){\n count++; \n }\n }\n return count;\n }\n private boolean isVowel(char c){\n return c == \'a\' || c == \'e\' || c == \'i\' || c == \'o\' || c == \'u\';\n }\n}\n``` | 2 | 0 | ['Java'] | 0 |
count-the-number-of-vowel-strings-in-range | simple solution | simple-solution-by-gnairju-ll1x | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | gnairju | NORMAL | 2024-01-05T04:05:49.240526+00:00 | 2024-01-05T04:05:49.240565+00:00 | 208 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution:\n def vowelStrings(self, words: List[str], left: int, right: int) -> int:\n v=\'aeiou\'\n c=0\n x=words[left:right+1]\n for i in x:\n if i[0] in v and i[len(i)-1] in v:\n c+=1\n return c\n``` | 2 | 0 | ['Python3'] | 1 |
count-the-number-of-vowel-strings-in-range | Easiest Python Solution | easiest-python-solution-by-deleted_user-96oi | Code\n\nclass Solution:\n def vowelStrings(self, words: List[str], left: int, right: int) -> int:\n v = [\'a\', \'e\', \'i\', \'o\', \'u\']\n a | deleted_user | NORMAL | 2023-10-29T09:04:08.494014+00:00 | 2023-10-29T09:04:08.494049+00:00 | 264 | false | # Code\n```\nclass Solution:\n def vowelStrings(self, words: List[str], left: int, right: int) -> int:\n v = [\'a\', \'e\', \'i\', \'o\', \'u\']\n ans = 0\n for i in words[left : right + 1]:\n if i[0] in v and i[-1] in v:\n ans += 1\n return ans\n``` | 2 | 0 | ['Python3'] | 0 |
count-the-number-of-vowel-strings-in-range | Easy Java Solution || Basic Approach || HashSet | easy-java-solution-basic-approach-hashse-axb2 | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | Piyush_S2002 | NORMAL | 2023-10-28T19:24:48.514268+00:00 | 2023-10-28T19:24:48.514285+00:00 | 66 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n public int vowelStrings(String[] words, int left, int right) {\n int count = 0;\n\n Set<Character> set = new HashSet<>();\n set.add(\'a\');\n set.add(\'e\');\n set.add(\'i\');\n set.add(\'o\');\n set.add(\'u\');\n\n for (int i = left; i <= right; i++) {\n int k = words[i].length();\n\n if (set.contains(words[i].charAt(0)) && set.contains(words[i].charAt(k - 1))) {\n count++;\n }\n }\n\n return count;\n }\n}\n``` | 2 | 0 | ['Hash Table', 'String', 'Java'] | 0 |
count-the-number-of-vowel-strings-in-range | 2586. Count the Number of Vowel Strings in Range using java | 2586-count-the-number-of-vowel-strings-i-gh77 | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | shivashish27 | NORMAL | 2023-09-10T17:49:49.994089+00:00 | 2023-09-10T17:49:49.994120+00:00 | 388 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n public int vowelStrings(String[] words, int left, int right) {\n int count = 0;\n for (int i = left; i <= right; i++) {\n String a = words[i];\n\n if (a.charAt(0) == \'a\' || a.charAt(0) == \'e\' || a.charAt(0) == \'i\' || a.charAt(0) == \'o\' || a.charAt(0) == \'u\') {\n if (a.charAt(a.length() - 1) == \'a\' || a.charAt(a.length() - 1) == \'e\' || a.charAt(a.length() - 1) == \'i\' || a.charAt(a.length() - 1) == \'o\' || a.charAt(a.length() - 1) == \'u\') {\n count++;\n }\n }\n }\n\n return count;\n }\n}\n\n\n\n\n``` | 2 | 0 | ['Java'] | 1 |
count-the-number-of-vowel-strings-in-range | Easy C++ Solution || Problem solve for Beginner's | easy-c-solution-problem-solve-for-beginn-y2tl | \n\n# Code\n\nclass Solution {\npublic:\n int vowelStrings(vector<string>& words, int left, int right) {\n int count=0;\n for(int it=left;it<=r | Manisha_jha658 | NORMAL | 2023-08-24T14:08:27.070115+00:00 | 2023-08-24T14:08:27.070211+00:00 | 20 | false | \n\n# Code\n```\nclass Solution {\npublic:\n int vowelStrings(vector<string>& words, int left, int right) {\n int count=0;\n for(int it=left;it<=right;it++){ //words[it][0] means int the string of words,first word and first letter of word.\n if(words[it][0]==\'a\'|| words[it][0]==\'e\'||words[it][0]==\'i\'||words[it][0]==\'o\'||words[it][0]==\'u\')\n {\n if(words[it][words[it].size()-1]==\'a\'|| words[it][words[it].size()-1]==\'e\'||words[it][words[it].size()-1]==\'i\'||words[it][words[it].size()-1]==\'o\'||words[it][words[it].size()-1]==\'u\')\n {\n count++;\n }\n }\n }\n return count;\n }\n};\n``` | 2 | 0 | ['C++'] | 0 |
count-the-number-of-vowel-strings-in-range | 0ms Runtime- Easy, Optimised solution in Java||C++||Python | 0ms-runtime-easy-optimised-solution-in-j-kt3y | Code\nJava []\nclass Solution {\n public int vowelStrings(String[] words, int left, int right) {\n int count=0;\n while(left<=right)\n { | phalakbh | NORMAL | 2023-07-10T12:05:48.707354+00:00 | 2023-07-10T12:05:48.707371+00:00 | 373 | false | # Code\n```Java []\nclass Solution {\n public int vowelStrings(String[] words, int left, int right) {\n int count=0;\n while(left<=right)\n {\n if(vowel(words[left].charAt(0))&&vowel(words[left].charAt(words[left].length()-1)))\n count++;\n left++;\n }\n return count;\n }\n boolean vowel(char ch)\n {\n if(ch==\'a\'||ch==\'e\'||ch==\'i\'||ch==\'o\'||ch==\'u\')\n return true;\n else return false;\n }\n}\n```\n```C++ []\nclass Solution {\npublic:\n int vowelStrings(vector<string>& words, int left, int right) {\n int count=0;\n for (int i=left;i<=right;i++)\n {\n if (isVowel(words[i].at(0)) && isVowel(words[i].at(words[i].size()-1)))\n count++;\n }\n return count;\n }\n bool isVowel(char s)\n {\n return (s==\'a\'||s==\'e\'||s==\'i\'||s==\'o\'||s==\'u\');\n }\n};\n```\n```Python []\nclass Solution(object):\n def vowelStrings(self, words, left, right):\n def isVowel(c):\n return c in [\'a\',\'e\',\'i\',\'o\',\'u\']\n count=0\n for i in range(left,right+1):\n if isVowel(words[i][0]) and isVowel(words[i][-1]):\n count+=1\n return count\n```\n | 2 | 0 | ['Array', 'String', 'Python', 'C++', 'Java'] | 0 |
count-the-number-of-vowel-strings-in-range | Beginner's Approach | beginners-approach-by-bhaskarkumar07-erh2 | \n\n# Complexity\n- Time complexity: O(N)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity:O(1)\n Add your space complexity here, e.g. O(n) \n\ | bhaskarkumar07 | NORMAL | 2023-06-04T06:48:51.880043+00:00 | 2023-07-05T17:20:30.027016+00:00 | 578 | false | \n\n# Complexity\n- Time complexity: O(N)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n public int vowelStrings(String[] words, int left, int right) {\n // String vowel="aeiouAEIOU";\n String vowel="aeiou";\n\n int count=0;\n\n for(int i=left;i<=right;i++){\n if(vowel.contains(String.valueOf(words[i].charAt(0))) && vowel.contains(String.valueOf(words[i].charAt(words[i].length()-1)))) count++;\n }\n\n return count;\n }\n}\n``` | 2 | 0 | ['Java'] | 1 |
count-the-number-of-vowel-strings-in-range | Count the Number of Vowel Strings in Range Solution in C++ | count-the-number-of-vowel-strings-in-ran-71um | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | The_Kunal_Singh | NORMAL | 2023-05-27T04:19:59.946276+00:00 | 2023-05-27T04:19:59.946312+00:00 | 213 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO(n)\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nO(1)\n# Code\n```\nclass Solution {\npublic:\n int vowelStrings(vector<string>& words, int left, int right) {\n int i, vowel_count=0;\n for(i=left ; i<=right ; i++)\n {\n if((words[i][0]==\'a\' || words[i][0]==\'e\' ||words[i][0]==\'i\' ||words[i][0]==\'o\' ||words[i][0]==\'u\') && (words[i][words[i].length()-1]==\'a\' || words[i][words[i].length()-1]==\'e\' ||words[i][words[i].length()-1]==\'i\' ||words[i][words[i].length()-1]==\'o\' ||words[i][words[i].length()-1]==\'u\'))\n {\n vowel_count++;\n }\n }\n return vowel_count;\n }\n};\n```\n\n | 2 | 0 | ['C++'] | 0 |
count-the-number-of-vowel-strings-in-range | Simple JAVA Solution for beginners. Ternary Operator. 1ms. Beats 100%. | simple-java-solution-for-beginners-terna-zrtp | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | sohaebAhmed | NORMAL | 2023-05-18T06:42:06.851729+00:00 | 2023-05-18T06:42:06.851773+00:00 | 174 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n public int vowelStrings(String[] words, int left, int right) {\n int count = 0;\n for(int i = left; i <= right; i++) {\n count += isVowel(words[i].charAt(0)) && isVowel(words[i].charAt(words[i].length() - 1)) ? 1 : 0;\n }\n return count;\n }\n\n boolean isVowel(char ch) {\n return ch == \'a\' || ch == \'e\' || ch == \'i\' || ch == \'o\' || ch == \'u\';\n }\n}\n``` | 2 | 0 | ['Array', 'String', 'Java'] | 0 |
count-the-number-of-vowel-strings-in-range | Simple JAVA Solution for beginners. 1ms. Beats 100%. | simple-java-solution-for-beginners-1ms-b-twem | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | sohaebAhmed | NORMAL | 2023-05-18T06:40:04.488735+00:00 | 2023-05-18T06:40:04.488783+00:00 | 802 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n public int vowelStrings(String[] words, int left, int right) {\n int count = 0;\n for(int i = left; i <= right; i++) {\n if(isVowel(words[i].charAt(0)) && isVowel(words[i].charAt(words[i].length() - 1))) {\n count++;\n }\n }\n return count;\n }\n\n boolean isVowel(char ch) {\n return ch == \'a\' || ch == \'e\' || ch == \'i\' || ch == \'o\' || ch == \'u\';\n }\n}\n``` | 2 | 0 | ['Array', 'String', 'Java'] | 0 |
count-the-number-of-vowel-strings-in-range | Easy Java solution with 1ms runtime | TC = O(n) | Beats 100% | easy-java-solution-with-1ms-runtime-tc-o-2tid | Complexity\n- Time complexity: O(n)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(1)\n Add your space complexity here, e.g. O(n) \n\n# Co | JavithSadhamHussain | NORMAL | 2023-03-22T07:52:57.221723+00:00 | 2023-03-22T07:52:57.221759+00:00 | 822 | false | # Complexity\n- Time complexity: O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n public int vowelStrings(String[] words, int left, int right) \n {\n int countOfVowelStrings = 0;\n\n for(int idx=left; idx<=right; idx++)\n {\n countOfVowelStrings += \n isVowel(words[idx].charAt(0)) && \n isVowel(words[idx].charAt(words[idx].length()-1))\n ? 1 : 0;\n }\n\n return countOfVowelStrings;\n }\n public boolean isVowel(char ch)\n {\n return ch == \'a\' || ch == \'e\' || ch == \'i\' || ch == \'o\' || ch == \'u\';\n }\n}\n``` | 2 | 0 | ['Java'] | 0 |
count-the-number-of-vowel-strings-in-range | Easy Java Soln | O(n) | easy-java-soln-on-by-luvkush_14-fd4t | Intuition\nAccessing strings from the words array one by one and checking whether they are vowel string or not. If Yes then increament the count variable by 1 e | luvkush_14 | NORMAL | 2023-03-16T14:17:48.651088+00:00 | 2023-03-16T14:17:48.651128+00:00 | 198 | false | # Intuition\nAccessing strings from the words array one by one and checking whether they are vowel string or not. If Yes then increament the count variable by 1 else remains the count variable as it is.\n\n\n# Complexity\n- Time complexity:\nO(n)\n\n- Space complexity:\nO(1)\n\n# Code\n```\nclass Solution {\n public int vowelStrings(String[] words, int left, int right) {\n\n int count = 0;\n\n for (int i = left; i <= right ; i++) {\n\n String s = words[i];\n\n if (Vowel (s.charAt(0)) && Vowel (s.charAt(s.length()-1))) {\n\n count += 1;\n }\n }\n\n return count;\n \n }\n\n public boolean Vowel (char ch) {\n\n if (ch == \'a\' || ch == \'e\' || ch == \'i\' || ch == \'o\' || ch == \'u\') {\n\n return true;\n }\n\n return false;\n }\n}\n``` | 2 | 0 | ['Java'] | 1 |
count-the-number-of-vowel-strings-in-range | Fastest solution 100% | fastest-solution-100-by-dheeraj94100-71wu | Intuition\n Traverse the array check whether a word start with a vowel or not and end with a vowel or not. \n\n# Complexity\n- Time complexity:\n O(n) \n\n- Spa | dheeraj94100 | NORMAL | 2023-03-16T14:17:24.952736+00:00 | 2023-03-16T14:17:24.952778+00:00 | 348 | false | # Intuition\n<!-- Traverse the array check whether a word start with a vowel or not and end with a vowel or not. -->\n\n# Complexity\n- Time complexity:\n<!-- O(n) -->\n\n- Space complexity:\n<!-- O(1) -->\n\n# Code\n```\nclass Solution {\n public int vowelStrings(String[] words, int left, int right) {\n int count = 0;\n for(int i = left;i <= right;i++)\n {\n String s = words[i];\n int a = s.length() - 1;\n if((s.charAt(0) == \'a\' || s.charAt(0) == \'e\' || s.charAt(0) == \'i\' || s.charAt(0) == \'o\' || s.charAt(0) == \'u\') && (s.charAt(a) == \'a\' || s.charAt(a) == \'e\' || s.charAt(a) == \'i\' || s.charAt(a) == \'o\' || s.charAt(a) == \'u\'))\n {\n count++;\n }\n }\n return count;\n }\n}\n``` | 2 | 0 | ['Java'] | 0 |
count-the-number-of-vowel-strings-in-range | Easy Java Solution using if | easy-java-solution-using-if-by-agdarshit-j67k | \n\n# Code\n\nclass Solution {\n public int vowelStrings(String[] words, int left, int right) {\n int ct = 0;\n for(int i = left ; i <= right ; i | agdarshit19 | NORMAL | 2023-03-15T10:11:48.302945+00:00 | 2023-03-15T10:11:48.302985+00:00 | 396 | false | \n\n# Code\n```\nclass Solution {\n public int vowelStrings(String[] words, int left, int right) {\n int ct = 0;\n for(int i = left ; i <= right ; i++)\n {\n String s = words[i];\n if((s.charAt(0) != \'a\' && s.charAt(0) != \'e\' && s.charAt(0) != \'i\' && s.charAt(0) != \'o\' && s.charAt(0) != \'u\') || (s.charAt(s.length() - 1) != \'a\' && s.charAt(s.length() - 1) != \'e\' && s.charAt(s.length() - 1) != \'i\' && s.charAt(s.length() - 1) != \'o\' && s.charAt(s.length() - 1) != \'u\'))\n {\n continue;\n } \n ct++; \n }\n return ct; \n }\n}\n``` | 2 | 0 | ['Java'] | 0 |
count-the-number-of-vowel-strings-in-range | Python3 Solution | python3-solution-by-motaharozzaman1996-nxmr | \n\n# Complexity\n- Time complexity:O(n)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity:O(1)\n Add your space complexity here, e.g. O(n) \n\n | Motaharozzaman1996 | NORMAL | 2023-03-14T04:18:01.418998+00:00 | 2023-03-14T04:18:01.419030+00:00 | 227 | false | \n\n# Complexity\n- Time complexity:O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution:\n def vowelStrings(self, words: List[str], left: int, right: int) -> int:\n vowels=\'aeiouAEIOU\'\n count=0\n for i in range(left,right+1):\n if words[i][0] in vowels and words[i][-1] in vowels:\n count+=1\n\n return count \n``` | 2 | 0 | ['Python', 'Python3'] | 0 |
count-the-number-of-vowel-strings-in-range | Java easy 100 % faster must checkout once! | java-easy-100-faster-must-checkout-once-g9loi | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | RishabhDixit1 | NORMAL | 2023-03-12T16:32:44.869254+00:00 | 2023-03-12T16:32:44.869290+00:00 | 91 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n public int vowelStrings(String[] words, int left, int right) {\n int count = 0;\n for(int i = left; i <= right; i++){\n String temp = words[i];\n int e = temp.length()-1;\n if((temp.charAt(0) == \'a\' ||temp.charAt(0) == \'e\' ||temp.charAt(0) == \'i\' ||temp.charAt(0) == \'o\' ||temp.charAt(0) == \'u\') &&(temp.charAt(e) == \'a\' ||temp.charAt(e) == \'e\' ||temp.charAt(e) == \'i\' ||temp.charAt(e) == \'o\' ||temp.charAt(e) == \'u\')){\n count++;\n }\n }\n return count;\n \n }\n}\n``` | 2 | 0 | ['Java'] | 0 |
count-the-number-of-vowel-strings-in-range | Python3 Very Simple Solution | python3-very-simple-solution-by-jagdtri2-ji02 | \n\n# Code\n\nclass Solution:\n def vowelStrings(self, words: List[str], left: int, right: int) -> int:\n ans=0\n vol="aeiou"\n\n for i | jagdtri2003 | NORMAL | 2023-03-12T14:12:23.091727+00:00 | 2023-03-12T14:12:23.091761+00:00 | 170 | false | \n\n# Code\n```\nclass Solution:\n def vowelStrings(self, words: List[str], left: int, right: int) -> int:\n ans=0\n vol="aeiou"\n\n for i in range(left,right+1):\n if words[i][0] in vol and words[i][-1] in vol:\n ans+=1\n return ans \n \n``` | 2 | 0 | ['Python3'] | 0 |
count-the-number-of-vowel-strings-in-range | ✅ C# | easy and readable solution 🚅 faster than 100% 💻 less than 100% | c-easy-and-readable-solution-faster-than-ogtu | \n\nDon\'t hesitate to suggest or ask bellow about something that you don\'t understand\n\n\npublic class Solution {\n public int VowelStrings(string[] words | Thanat05 | NORMAL | 2023-03-12T12:49:45.360624+00:00 | 2023-03-12T12:49:45.360664+00:00 | 142 | false | \n\n**Don\'t hesitate to suggest or ask bellow about something that you don\'t understand**\n\n```\npublic class Solution {\n public int VowelStrings(string[] words, int left, int right) {\n int counter = 0;\n string vowels = "aeiou";\n for (int i = left; i <= right; i++)\n {\n int length = words[i].Length - 1;\n if (vowels.Contains(words[i][0]) && vowels.Contains(words[i][length]))\n counter++;\n }\n return counter;\n }\n}\n```\n\nIf you like it don\'t forget to **upvote!** | 2 | 0 | ['C#'] | 0 |
count-the-number-of-vowel-strings-in-range | 😁🙌Simple & Easy Solution | simple-easy-solution-by-tamosakatwa-g9x4 | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | tamosakatwa | NORMAL | 2023-03-12T05:05:14.792899+00:00 | 2023-03-12T05:05:14.792944+00:00 | 246 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n public int vowelStrings(String[] words, int left, int right) {\n int count=0;\n for(int i=left;i<=right;i++){\n char l=words[i].charAt(0);\n char r=words[i].charAt(words[i].length()-1);\n if((l==\'a\'||l==\'e\'||l==\'i\'||l==\'o\'||l==\'u\') && (r==\'a\'||r==\'e\'||r==\'i\'||r==\'o\'||r==\'u\')){\n count++;\n }\n }\n return count;\n }\n}\n``` | 2 | 0 | ['Java'] | 0 |
count-the-number-of-vowel-strings-in-range | easy short efficient clean code | easy-short-efficient-clean-code-by-maver-16xc | \nclass Solution {\npublic:\n bool isValid(const char&ch){\n return (ch==\'a\' || ch==\'e\' || ch==\'i\' || ch==\'o\' || ch==\'u\');\n }\n int v | maverick09 | NORMAL | 2023-03-12T04:04:25.874937+00:00 | 2023-03-12T04:04:25.874988+00:00 | 536 | false | ```\nclass Solution {\npublic:\n bool isValid(const char&ch){\n return (ch==\'a\' || ch==\'e\' || ch==\'i\' || ch==\'o\' || ch==\'u\');\n }\n int vowelStrings(vector<string>& words, int left, int right) {\n int ans=0;\n for(int i=left;i<=right;++i){\n if(isValid(words[i].front()) && isValid(words[i].back())){\n ++ans;\n }\n }\n return ans;\n }\n};\n``` | 2 | 0 | ['C'] | 0 |
count-the-number-of-vowel-strings-in-range | VERY EASY SOLUTION USING ARRAYLIST || EASY TO UNDERSTAND | very-easy-solution-using-arraylist-easy-rdwws | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | mohit6395 | NORMAL | 2025-03-18T06:03:42.244794+00:00 | 2025-03-18T06:03:42.244794+00:00 | 135 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
# Approach
<!-- Describe your approach to solving the problem. -->
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
# Code
```java []
class Solution {
public int vowelStrings(String[] words, int left, int right) {
ArrayList<Character>mo=new ArrayList<>();
int count=0;
mo.add('a');
mo.add('e');
mo.add('i');
mo.add('o');
mo.add('u');
for(int i=left;i<=right;i++){
String word=words[i];
if(mo.contains(word.charAt(0))&&mo.contains(word.charAt(word.length()-1))) count++;
}
return count;
}
}
``` | 1 | 0 | ['Java'] | 0 |
count-the-number-of-vowel-strings-in-range | 0ms C++ | find in vector array of vowels | 0ms-c-find-in-vector-array-of-vowels-by-35bqb | Intuition & ApproachComplexity
Time complexity:
Space complexity:
Code | amithm7 | NORMAL | 2025-01-22T06:49:06.959451+00:00 | 2025-01-22T06:49:06.959451+00:00 | 112 | false | # Intuition & Approach
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
# Code
```cpp []
class Solution {
public:
int vowelStrings(vector<string>& words, int left, int right) {
int c = 0;
vector<char> v = {'a', 'e', 'i', 'o', 'u'};
for (; left <= right; left++) {
string s = words[left];
char b = s[0], e = s[s.size() - 1];
if (find(v.begin(), v.end(), b) != v.end() &&
find(v.begin(), v.end(), e) != v.end())
c++;
}
return c;
}
};
``` | 1 | 0 | ['C++'] | 0 |
count-the-number-of-vowel-strings-in-range | Simple and Clear Java Solution | Easy to Understand with O(n) Complexity | simple-and-clear-java-solution-easy-to-u-ch0z | IntuitionTo solve the problem, we need to check each string in the specified range to determine if it starts and ends with a vowel. Using a list of vowels allow | ayush03ch | NORMAL | 2025-01-18T14:41:13.080504+00:00 | 2025-01-18T14:41:13.080504+00:00 | 91 | false | # Intuition
To solve the problem, we need to check each string in the specified range to determine if it starts and ends with a vowel. Using a list of vowels allows us to efficiently verify these conditions for each string. We extract each of the word's first and last character and check whether they are vowels or not.
# Approach
1. Create a list containing all vowels (a, e, i, o, u).
2. Use a for loop to iterate through the range [left, right].
3. For each string, check if the first and last characters are in the vowel list.
4. If both conditions are true, increment the count.
5. Return the final count after iterating through the range.
# Complexity
- **Time complexity** : O(n), where n=(right−left+1), due to the for loop iterating through the range.
- **Space complexity** : O(1), as the vowels list uses constant space
# Code
```java []
class Solution {
public int vowelStrings(String[] words, int left, int right) {
int count = 0;
List<Character> vowels = new ArrayList<>();
vowels.add('a');
vowels.add('e');
vowels.add('i');
vowels.add('o');
vowels.add('u');
for(int i=left; i<=right; i++){
String word = words[i];
if(vowels.contains(word.charAt(0)) && vowels.contains(word.charAt(word.length()-1)))
count++;
}
return count;
}
}
``` | 1 | 0 | ['Java'] | 0 |
count-the-number-of-vowel-strings-in-range | Simple and Clear Java Solution | Easy to Understand with O(n) Complexity | simple-and-clear-java-solution-easy-to-u-99y3 | IntuitionTo solve the problem, we need to check each string in the specified range to determine if it starts and ends with a vowel. Using a list of vowels allow | ayush03ch | NORMAL | 2025-01-18T14:41:08.192947+00:00 | 2025-01-18T14:41:08.192947+00:00 | 55 | false | # Intuition
To solve the problem, we need to check each string in the specified range to determine if it starts and ends with a vowel. Using a list of vowels allows us to efficiently verify these conditions for each string. We extract each of the word's first and last character and check whether they are vowels or not.
# Approach
1. Create a list containing all vowels (a, e, i, o, u).
2. Use a for loop to iterate through the range [left, right].
3. For each string, check if the first and last characters are in the vowel list.
4. If both conditions are true, increment the count.
5. Return the final count after iterating through the range.
# Complexity
- **Time complexity** : O(n), where n=(right−left+1), due to the for loop iterating through the range.
- **Space complexity** : O(1), as the vowels list uses constant space
# Code
```java []
class Solution {
public int vowelStrings(String[] words, int left, int right) {
int count = 0;
List<Character> vowels = new ArrayList<>();
vowels.add('a');
vowels.add('e');
vowels.add('i');
vowels.add('o');
vowels.add('u');
for(int i=left; i<=right; i++){
String word = words[i];
if(vowels.contains(word.charAt(0)) && vowels.contains(word.charAt(word.length()-1)))
count++;
}
return count;
}
}
``` | 1 | 0 | ['Java'] | 0 |
count-the-number-of-vowel-strings-in-range | 100% Using simple slicing of string. | 100-using-simple-slicing-of-string-by-sa-7o1u | Intuition\nThe first thought came in my mind is to use slicing.\n\n Describe your first thoughts on how to solve this problem. \n\n# Approach\nIterate over low | sagar_shukla69 | NORMAL | 2024-11-21T10:35:22.530242+00:00 | 2024-11-21T10:35:22.530286+00:00 | 36 | false | # Intuition\nThe first thought came in my mind is to use slicing.\n\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\nIterate over low to high\nIf the string\'s first letter and last\'s letter belongs to the vowel string as made previously(vowel=\'aeiou\')\nIf the condition is true then increae the count by 1.\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n- O(N)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n-\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```python3 []\nclass Solution:\n def vowelStrings(self, words: List[str], left: int, right: int) -> int:\n c=0\n vowel=\'aeiou\'\n for i in range(left,right+1):\n if words[i][0] in vowel and words[i][-1] in vowel:\n c+=1\n return c \n \n``` | 1 | 0 | ['Python3'] | 0 |
count-the-number-of-vowel-strings-in-range | Java simple solution | java-simple-solution-by-jayasurya_m-d5jt | \n\n# Code\njava []\nclass Solution {\n public int vowelStrings(String[] words, int left, int right) {\n int count=0;\n for(int i= left;i<=righ | JAYASURYA_M | NORMAL | 2024-10-28T16:34:44.674965+00:00 | 2024-10-28T16:34:44.675069+00:00 | 27 | false | \n\n# Code\n```java []\nclass Solution {\n public int vowelStrings(String[] words, int left, int right) {\n int count=0;\n for(int i= left;i<=right;i++)\n {\n if((words[i].charAt(0)==\'a\'||words[i].charAt(0)==\'e\'||words[i].charAt(0)==\'i\'||words[i].charAt(0)==\'o\'||words[i].charAt(0)==\'u\')&&(words[i].charAt(words[i].length()-1)==\'a\'||words[i].charAt(words[i].length()-1)==\'e\'||words[i].charAt(words[i].length()-1)==\'i\'||words[i].charAt(words[i].length()-1)==\'o\'||words[i].charAt(words[i].length()-1)==\'u\') )\n {\n count++;\n }\n }\n return count;\n \n }\n}\n``` | 1 | 0 | ['Java'] | 0 |
count-the-number-of-vowel-strings-in-range | Beats 82% Loop + simple condition | beats-82-loop-simple-condition-by-nomadd-2xab | Intuition\n Describe your first thoughts on how to solve this problem. \nNeed to loop array of words from left to right to copmare first and last symbol\n\n# Ap | nomaddis | NORMAL | 2024-10-03T15:56:12.998259+00:00 | 2024-10-03T15:56:12.998288+00:00 | 22 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nNeed to loop array of words from left to right to copmare first and last symbol\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1. Create set of vowels\n2. Loop words from left to right\n3. Check if words starts and ends from vowel by searching in arrray of vowels. Increment counter if yes\n4. Return counter\n\n# Complexity\n- Time complexity: O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```javascript []\n/**\n * @param {string[]} words\n * @param {number} left\n * @param {number} right\n * @return {number}\n */\nconst vowels = new Set([\'a\', \'e\', \'i\', \'o\', \'u\']);\nvar vowelStrings = function(words, left, right) {\n let count = 0;\n for(let i = left; i<=right; i++) {\n if (vowels.has(words[i][0]) && vowels.has(words[i].at(-1))) {\n count++\n }\n }\n\n return count\n};\n``` | 1 | 0 | ['JavaScript'] | 0 |
count-the-number-of-vowel-strings-in-range | simple one PYTHON | simple-one-python-by-justingeorge-piim | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | justingeorge | NORMAL | 2024-03-01T10:21:31.062355+00:00 | 2024-03-01T10:21:31.062388+00:00 | 4 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution:\n def vowelStrings(self, words: List[str], left: int, right: int) -> int:\n\n v=[\'a\',\'e\',\'i\',\'o\',\'u\']\n count=0\n\n for i in range(left,right+1):\n if words[i][0] in v and words[i][-1] in v:\n count=count+1\n return count\n\n\n \n``` | 1 | 0 | ['Python3'] | 0 |
count-the-number-of-vowel-strings-in-range | C++ || Simple Solution | c-simple-solution-by-kriti___raj-7vu7 | # Intuition \n\n\n\n\n\n# Complexity\n- Time complexity:O(n*m)\n\n\n- Space complexity:O(1)\n\n\n# Code\n\nclass Solution {\npublic:\n bool isvowel(char st | kriti___raj | NORMAL | 2023-11-23T18:15:41.364626+00:00 | 2023-11-23T18:15:41.364654+00:00 | 408 | false | <!-- # Intuition -->\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n<!-- # Approach -->\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:$$O(n*m)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:$$O(1)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n bool isvowel(char str){\n if(str == \'a\' || str == \'e\' || str == \'i\' || str == \'o\' || str == \'u\') return 1;\n return 0;\n }\n int vowelStrings(vector<string>& words, int left, int right) {\n int count=0;\n for(int i=left; i<=right; i++){\n int siz = words[i].size()-1;\n if(isvowel(words[i][0]) && isvowel(words[i][siz])) count++;\n }\n return count;\n }\n};\n```\n---\n\n\n | 1 | 0 | ['C++'] | 0 |
count-the-number-of-vowel-strings-in-range | Simple solution in Python3 | simple-solution-in-python3-by-subscriber-vt1o | Intuition\nHere we have:\n- words list, left and right integers\n- we should find all of the vowel strings for [left, right] interval from words\n\nVowel string | subscriber6436 | NORMAL | 2023-11-23T17:00:15.570870+00:00 | 2023-11-23T17:00:15.570897+00:00 | 11 | false | # Intuition\nHere we have:\n- `words` list, `left` and `right` integers\n- we should find all of the **vowel** strings for `[left, right]` interval from `words`\n\n**Vowel strings** have the starting and the ending character as **vowel**. \n\n# Approach\n1. define `check` function to check if a character is a **vowel**\n2. declare `ans`\n3. iterate over `[left, right]` and find these strings with `check`\n4. return `ans`\n\n# Complexity\n- Time complexity: **O(N)**, to iterate over `words`\n\n- Space complexity: **O(1)**, we don\'t allocate extra space.\n\n# Code\n```\nclass Solution:\n def vowelStrings(self, words: list[str], left: int, right: int) -> int:\n def isVowelString(str):\n check = lambda char: char == \'a\' or char == \'e\' or char == \'i\' or char == \'o\' or char == \'u\'\n\n return check(str[0]) and check(str[-1])\n\n ans = 0\n\n for i in range(left, right + 1):\n ans += int(isVowelString(words[i]))\n\n return ans \n``` | 1 | 0 | ['String', 'Python3'] | 0 |
count-the-number-of-vowel-strings-in-range | 99% and 98% user beat.....in Python3 | 99-and-98-user-beatin-python3-by-pgupta2-s6sg | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | pgupta246 | NORMAL | 2023-10-22T10:37:42.060152+00:00 | 2023-10-22T10:37:42.060170+00:00 | 8 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution:\n def vowelStrings(self, words: List[str], left: int, right: int) -> int:\n v=["a","e","i","o","u"]\n s=0\n for i in words[left:right+1]:\n if (i[0] in v) and (i[-1] in v) :\n s=s+1\n return s\n \n``` | 1 | 0 | ['Python3'] | 0 |
count-the-number-of-vowel-strings-in-range | JAVA SOLUTION || 100% FASTER SOLUTION | java-solution-100-faster-solution-by-vip-n9f1 | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | viper_01 | NORMAL | 2023-09-06T19:30:07.938454+00:00 | 2023-09-06T19:30:07.938485+00:00 | 3 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n public int vowelStrings(String[] words, int left, int right) {\n String vowels = "aeiou";\n\n int ans = 0;\n\n for(int i = left; i <= right; i++) {\n String word = words[i];\n\n if(vowels.indexOf(word.charAt(0)) != -1 && vowels.indexOf(word.charAt(word.length() - 1)) != -1)\n ans++;\n }\n\n return ans;\n }\n}\n``` | 1 | 0 | ['Java'] | 0 |
count-the-number-of-vowel-strings-in-range | Easy Solution || JS || Understanding Solution | easy-solution-js-understanding-solution-9llru | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | Vrund9 | NORMAL | 2023-08-25T19:06:58.228404+00:00 | 2023-08-25T19:06:58.228426+00:00 | 47 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\n/**\n * @param {string[]} words\n * @param {number} left\n * @param {number} right\n * @return {number}\n */\nvar vowelStrings = function(words, left, right) {\n let vowelCount = 0\n let arr = [\'a\', \'e\', \'i\', \'o\', \'u\']\n for (let i = left; i <= right; i++) {\n if (arr.includes(words[i].charAt(0)) && arr.includes(words[i].charAt(words[i].length-1))) {\n vowelCount+=1\n }\n }\n return vowelCount\n};\n``` | 1 | 0 | ['JavaScript'] | 0 |
count-the-number-of-vowel-strings-in-range | Javascript with Reduce and Slice - Simple | javascript-with-reduce-and-slice-simple-1ix3z | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | brijesh178 | NORMAL | 2023-08-25T15:46:30.608457+00:00 | 2023-08-25T15:46:30.608480+00:00 | 224 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\n/**\n * @param {string[]} words\n * @param {number} left\n * @param {number} right\n * @return {number}\n */\nvar vowelStrings = function (words, left, right) {\n const vowel = "aeiou"\n return words.reduce((acc, item, index, array) => {\n if (\n index >= left &&\n index <= right &&\n vowel.includes(item.slice(0, 1)) &&\n vowel.includes(item.slice(item.length - 1, item.length))\n ) {\n acc += 1\n }\n return acc\n }, 0)\n}\n``` | 1 | 0 | ['JavaScript'] | 0 |
count-the-number-of-vowel-strings-in-range | SIMPLE RECURSIVE C++ SOLUTION ✅⚡ | simple-recursive-c-solution-by-shreealag-vwmm | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | ShreeAlagh | NORMAL | 2023-07-26T15:31:52.233182+00:00 | 2023-07-27T11:37:18.873542+00:00 | 203 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO(N)\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nO(N) for the auxilliary stack-space if you want to consider it..\nelse its O(1)\n\n# Code\n```\nclass Solution {\npublic:\nbool isVowel(char ch)\n{\n if(ch==\'a\' || ch==\'e\' || ch==\'i\' || ch==\'o\' || ch==\'u\')\n {\n return true;\n }\n return false;\n}\nint f(int idx,vector<string>&words,int end)\n{\n if(idx==end)\n {\n return isVowel(words[idx][0]) && isVowel(words[idx][words[idx].length()-1]);\n }\n\n if(isVowel(words[idx][0]) && isVowel(words[idx][words[idx].length()-1]))\n {\n return 1+f(idx+1,words,end);\n }\n return 0+f(idx+1,words,end);\n}\n int vowelStrings(vector<string>& words, int left, int right) {\n return f(left,words,right);\n }\n};\n``` | 1 | 0 | ['Recursion', 'C++'] | 0 |
count-the-number-of-vowel-strings-in-range | Easy and Simple Approach in Java, C++ and Python ||0 ms runtime in Java|| | easy-and-simple-approach-in-java-c-and-p-g6cu | Java []\nclass Solution {\n public int vowelStrings(String[] words, int left, int right) {\n int count=0;\n while(left<=right)\n {\n | _veer_singh04_ | NORMAL | 2023-07-10T12:01:43.876156+00:00 | 2023-07-10T12:01:55.428750+00:00 | 117 | false | ```Java []\nclass Solution {\n public int vowelStrings(String[] words, int left, int right) {\n int count=0;\n while(left<=right)\n {\n if(vowel(words[left].charAt(0))&&vowel(words[left].charAt(words[left].length()-1)))\n count++;\n left++;\n }\n return count;\n }\n boolean vowel(char ch)\n {\n if(ch==\'a\'||ch==\'e\'||ch==\'i\'||ch==\'o\'||ch==\'u\')\n return true;\n else return false;\n }\n}\n```\n```C++ []\nclass Solution {\npublic:\n int vowelStrings(vector<string>& words, int left, int right) {\n int count=0;\n for (int i=left;i<=right;i++)\n {\n if (isVowel(words[i].at(0)) && isVowel(words[i].at(words[i].size()-1)))\n count++;\n }\n return count;\n }\n bool isVowel(char s)\n {\n return (s==\'a\'||s==\'e\'||s==\'i\'||s==\'o\'||s==\'u\');\n }\n};\n```\n```Python []\nclass Solution(object):\n def vowelStrings(self, words, left, right):\n def isVowel(c):\n return c in [\'a\',\'e\',\'i\',\'o\',\'u\']\n count=0\n for i in range(left,right+1):\n if isVowel(words[i][0]) and isVowel(words[i][-1]):\n count+=1\n return count\n```\n | 1 | 0 | ['String', 'Counting', 'C++', 'Java'] | 0 |
count-the-number-of-vowel-strings-in-range | Java Easy to Understand Solution | java-easy-to-understand-solution-by-brot-5yif | Code\n\nclass Solution {\n public int vowelStrings(String[] words, int left, int right) {\n int count = 0;\n\t\tList<Character> vowels = new ArrayList | brothercode | NORMAL | 2023-06-18T16:17:36.924526+00:00 | 2023-06-18T16:17:36.924556+00:00 | 4 | false | # Code\n```\nclass Solution {\n public int vowelStrings(String[] words, int left, int right) {\n int count = 0;\n\t\tList<Character> vowels = new ArrayList<Character>(); // Building a character map.\n\t\tvowels.add(\'a\');\n\t\tvowels.add(\'e\');\n\t\tvowels.add(\'i\');\n\t\tvowels.add(\'o\');\n\t\tvowels.add(\'u\');\n\t\tfor (int i = left; i <= right; i++) { // Setting the boundary\n\t\t\tif (vowels.contains(words[i].charAt(0)) && vowels.contains(words[i].charAt(words[i].length() - 1))) // Verifying if the start and end of the words are vowels.\n\t\t\t\tcount++;\n\t\t}\n\t\treturn count;\n }\n}\n``` | 1 | 0 | ['Java'] | 0 |
count-the-number-of-vowel-strings-in-range | Easy c++ solution | easy-c-solution-by-delibinitz-tugc | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | DELIBINITZ | NORMAL | 2023-05-05T18:24:26.262806+00:00 | 2023-05-05T18:24:26.262854+00:00 | 32 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n bool isVovel(char ch){\n return (ch == \'a\' || ch == \'e\' || ch == \'i\' || ch == \'o\' || ch == \'u\');\n }\n int vowelStrings(vector<string>& words, int left, int right) {\n int sol = 0;\n for(int i = left; i <= right; i++){\n if(isVovel(words[i][0])&&isVovel(words[i][words[i].size()-1]))sol++;\n }\n return sol;\n }\n};\n``` | 1 | 0 | ['C++'] | 0 |
count-the-number-of-vowel-strings-in-range | [c++ & Python] easy O(n) solution | c-python-easy-on-solution-by-augus7-qtgh | \n Describe your approach to solving the problem. \n\n# Complexity\n- Time complexity: O(n)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O | Augus7 | NORMAL | 2023-04-24T17:31:07.922020+00:00 | 2023-04-24T17:31:07.922065+00:00 | 39 | false | \n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: $$O(n)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(1)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# C++\n```\nclass Solution {\npublic:\n int vowelStrings(vector<string>& words, int left, int right) {\n unordered_set<int> st {\'a\', \'e\',\'i\', \'o\', \'u\'};\n int count = 0;\n for(int i = left; i <= right; i++) {\n if(st.find(words[i][0]) != st.end() && st.find(words[i][words[i].size()-1]) != st.end()) {\n count++;\n }\n }\n return count;\n }\n};\n```\n\n# Python / Python3\n```\nclass Solution:\n def vowelStrings(self, word: List[str], left: int, right: int) -> int:\n count = 0\n st = {\'a\', \'e\', \'i\', \'o\', \'u\'}\n for i in range(left, right+1):\n if(word[i][0] in st and word[i][len(word[i]) - 1] in st):\n count += 1\n return count\n``` | 1 | 0 | ['Array', 'String', 'Python', 'C++', 'Python3'] | 0 |
count-the-number-of-vowel-strings-in-range | Simple Kotlin solution | simple-kotlin-solution-by-armat-dzga | Code\n\nclass Solution {\n private val vowels = "aeiou"\n\n fun vowelStrings(words: Array<String>, left: Int, right: Int): Int =\n (left..right).co | armat | NORMAL | 2023-04-21T14:44:16.712450+00:00 | 2023-04-21T14:44:16.712491+00:00 | 23 | false | # Code\n```\nclass Solution {\n private val vowels = "aeiou"\n\n fun vowelStrings(words: Array<String>, left: Int, right: Int): Int =\n (left..right).count { i ->\n vowels.contains(words[i].first()) && vowels.contains(words[i].last())\n }\n}\n``` | 1 | 0 | ['Kotlin'] | 0 |
count-the-number-of-vowel-strings-in-range | SMARTEST way with JAVA(1ms) | smartest-way-with-java1ms-by-amin_aziz-0lqx | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | amin_aziz | NORMAL | 2023-04-15T04:52:04.569274+00:00 | 2023-04-15T04:52:04.569308+00:00 | 62 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n public boolean isVovel(char a){\n return a == \'a\' || a == \'e\' || a == \'i\' || a == \'o\' || a == \'u\';\n }\n public int vowelStrings(String[] words, int left, int right) {\n String vovels = "aeiou";\n int count = 0;\n for(int a = left; a <= right; a++){\n String word = words[a];\n char cap = word.charAt(0);\n char last = word.charAt(word.length()-1);\n if(isVovel(cap) && isVovel(last)){\n count++;\n }\n }\n return count;\n }\n}\n``` | 1 | 0 | ['Java'] | 0 |
count-the-number-of-vowel-strings-in-range | Different approach | different-approach-by-omanandpandey-rq8c | Complexity\n- Time complexity: O(n)\n- Space complexity: O(5)\n# Code\n\nclass Solution {\npublic:\n int vowelStrings(vector<string>& words, int left, int ri | OmAnandPandey | NORMAL | 2023-03-31T15:42:38.334157+00:00 | 2023-03-31T15:42:38.334193+00:00 | 204 | false | # Complexity\n- Time complexity: O(n)\n- Space complexity: O(5)\n# Code\n```\nclass Solution {\npublic:\n int vowelStrings(vector<string>& words, int left, int right) {\n unordered_map<char, int> check={{\'a\', 1}, {\'e\', 1}, {\'i\', 1}, {\'o\', 1}, {\'u\', 1}};\n int cnt = 0;\n for(int i = left; i <= right; i++)\n if(check.count(words[i][0]) and check.count(words[i][words[i].length()-1]))\n cnt++;\n return cnt;\n }\n};\n``` | 1 | 0 | ['C++'] | 0 |
count-the-number-of-vowel-strings-in-range | C easy-understanding | c-easy-understanding-by-morrismoppp-zyjr | Code\n\nint vowelStrings(char ** words, int wordsSize, int left, int right){\n char vowel[5]={\'a\',\'e\',\'i\',\'o\',\'u\'};\n int ans = 0;\n for(int | morrismoppp | NORMAL | 2023-03-31T07:20:12.548973+00:00 | 2023-03-31T07:20:12.549012+00:00 | 88 | false | # Code\n```\nint vowelStrings(char ** words, int wordsSize, int left, int right){\n char vowel[5]={\'a\',\'e\',\'i\',\'o\',\'u\'};\n int ans = 0;\n for(int i=left;i<=right;i++){\n int s=0,e=0;\n for(int j=0;j<5;j++){\n if(vowel[j]==words[i][0]){\n s=1;\n }\n if(vowel[j]==words[i][strlen(words[i])-1]){\n e=1;\n }\n }\n if(s==1 && e==1){\n ans++;\n }\n }\n return ans;\n}\n``` | 1 | 0 | ['C'] | 0 |
count-the-number-of-vowel-strings-in-range | Easy to Understand Python Solution || Beats 90% of other solutions | easy-to-understand-python-solution-beats-w5gp | Please Upvote if you like it.\n```\nclass Solution:\n def vowelStrings(self, words: List[str], left: int, right: int) -> int:\n a = ["a","e","i","o"," | Debasish365 | NORMAL | 2023-03-29T16:48:00.055119+00:00 | 2023-03-29T16:48:00.055160+00:00 | 95 | false | Please Upvote if you like it.\n```\nclass Solution:\n def vowelStrings(self, words: List[str], left: int, right: int) -> int:\n a = ["a","e","i","o","u"]\n count = 0\n for i in range(left,right+1):\n temp= words[i]\n if temp[0] in a and temp[-1] in a:\n count += 1\n return count | 1 | 0 | ['Python', 'Python3'] | 0 |
count-the-number-of-vowel-strings-in-range | Faster than 94% Very Easy JavaScript Solution !!!!!!!!!!!!!!!!!!!!!! | faster-than-94-very-easy-javascript-solu-9blo | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | harsh_sutaria_25 | NORMAL | 2023-03-27T13:43:13.798583+00:00 | 2023-03-27T13:43:13.798622+00:00 | 312 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\n/**\n * @param {string[]} words\n * @param {number} left\n * @param {number} right\n * @return {number}\n */\nvar vowelStrings = function(s, left, right) {\n let vowel = [\'a\',\'e\',\'i\',\'o\',\'u\']\n let count = 0 \n for(let i = left ; i <= right ;i++){\n if(vowel.includes(s[i][0]) && vowel.includes(s[i][s[i].length -1])){\n count +=1\n }\n } \n return count \n};\n``` | 1 | 0 | ['JavaScript'] | 1 |
count-the-number-of-vowel-strings-in-range | as simple as it is | 60ms | readable solution | as-simple-as-it-is-60ms-readable-solutio-3gwg | Code\n\nclass Solution:\n def vowelStrings(self, words: List[str], left: int, right: int) -> int:\n vowels = [\'a\', \'e\', \'i\', \'o\', \'u\']\n | Saltkroka | NORMAL | 2023-03-24T09:58:56.280361+00:00 | 2023-03-26T09:23:46.250450+00:00 | 10 | false | # Code\n```\nclass Solution:\n def vowelStrings(self, words: List[str], left: int, right: int) -> int:\n vowels = [\'a\', \'e\', \'i\', \'o\', \'u\']\n k = 0\n for i in range(left, right+1):\n if words[i][0] in vowels and words[i][-1] in vowels:\n k += 1\n return k\n``` | 1 | 0 | ['Python', 'Python3'] | 0 |
count-the-number-of-vowel-strings-in-range | Simple python iterative approach | simple-python-iterative-approach-by-sadd-a3oo | Intuition\nThis a simple string problem. We can solve it simple iterative approach.\n\n# Approach\nIterative approach.\n\n# Complexity\n- Time complexity: O(n) | saddamhr | NORMAL | 2023-03-24T03:02:52.687242+00:00 | 2023-03-24T03:02:52.687309+00:00 | 817 | false | # Intuition\nThis a simple string problem. We can solve it simple iterative approach.\n\n# Approach\nIterative approach.\n\n# Complexity\n- Time complexity: $$O(n)$$ - Linear Time\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(1)$$ - Constant Time\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution:\n def isVowel(self, char):\n return True if char in (\'A\', \'E\', \'I\', \'O\', \'U\', \'a\', \'e\', \'i\', \'o\', \'u\') else False\n def vowelStrings(self, words: List[str], left: int, right: int) -> int:\n count = 0\n for i in range(left, right+1):\n wordLen = len(words[i])\n if self.isVowel(words[i][0]) and self.isVowel(words[i][-1]):\n count += 1 \n return count\n\n``` | 1 | 0 | ['Python3'] | 0 |
count-the-number-of-vowel-strings-in-range | Simple Java Solution ♨️ || Beats 100%|| Simple looping | simple-java-solution-beats-100-simple-lo-ystu | \n\n# Code\n\nclass Solution {\n public int vowelStrings(String[] words, int left, int right) {\n int count = 0;\n for(int i = left;i<right+1;i | Ritabrata_1080 | NORMAL | 2023-03-19T05:52:59.007795+00:00 | 2023-03-19T05:53:46.601683+00:00 | 5 | false | \n\n# Code\n```\nclass Solution {\n public int vowelStrings(String[] words, int left, int right) {\n int count = 0;\n for(int i = left;i<right+1;i++){\n String query = words[i];\n if(isVowel(query.charAt(0)) && isVowel(query.charAt(query.length()-1))){\n count++;\n }\n }\n return count;\n }\n\n\n public boolean isVowel(char c){\n if(c == \'a\' || c == \'e\' || c == \'i\' || c == \'o\' || c == \'u\'){\n return true;\n }\n return false;\n }\n}\n``` | 1 | 0 | ['Java'] | 0 |
count-the-number-of-vowel-strings-in-range | Beats 100% solution | beats-100-solution-by-veds-posl | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | Veds_ | NORMAL | 2023-03-17T14:24:24.420126+00:00 | 2023-03-17T14:24:24.420159+00:00 | 15 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n public int vowelStrings(String[] words, int left, int right) {\n int p=0;\n for(int i=left;i<=right;i++)\n {\n int k=words[i].charAt(0);\n int s=words[i].charAt(words[i].length()-1);\n if((k==\'a\'||k==\'e\'||k==\'i\'||k==\'o\'||k==\'u\') && (s==\'a\'||s==\'e\'||s==\'i\'||s==\'o\'||s==\'u\'))\n p++;\n }\n return p;\n }\n}\n``` | 1 | 0 | ['Java'] | 0 |
count-the-number-of-vowel-strings-in-range | ✅ Swift: Easy to Understand and Simple Solution | swift-easy-to-understand-and-simple-solu-qinj | \n\n# Code\n\nclass Solution {\n func vowelStrings(_ words: [String], _ left: Int, _ right: Int) -> Int {\n let vowels = "aeiou"\n var ans = 0\ | sohagkumarbiswas | NORMAL | 2023-03-17T04:11:56.833721+00:00 | 2023-03-17T04:11:56.833748+00:00 | 104 | false | \n\n# Code\n```\nclass Solution {\n func vowelStrings(_ words: [String], _ left: Int, _ right: Int) -> Int {\n let vowels = "aeiou"\n var ans = 0\n \n for i in left...right{\n if vowels.contains(words[i].first!) && vowels.contains(words[i].last!){\n ans += 1\n }\n }\n \n return ans\n }\n}\n\n``` | 1 | 0 | ['Swift'] | 0 |
count-the-number-of-vowel-strings-in-range | Easy solution | easy-solution-by-dev1sh-741o | Intuition\n\n\n# Approach\n\n\n# Complexity\n- Time complexity:\n\n\n- Space complexity:\n\n\n# Code\n\nclass Solution {\npublic:\n int vowelStrings(vector<s | Dev1sh | NORMAL | 2023-03-16T12:41:39.833541+00:00 | 2023-03-16T12:41:39.833579+00:00 | 196 | false | # Intuition\n\n\n# Approach\n\n\n# Complexity\n- Time complexity:\n\n\n- Space complexity:\n\n\n# Code\n```\nclass Solution {\npublic:\n int vowelStrings(vector<string>& words, int left, int right) {\n int ans =0;\n for(int i = left ; i<=right; i++){\n string f = words[i];\n int si = words[i].size();\n if((f[0]==\'a\'||f[0]==\'e\'||f[0]==\'i\'||f[0]==\'o\'||f[0]==\'u\')&&(f[si-1]==\'a\' || f[si-1]==\'e\'|| f[si-1]==\'i\' || f[si-1]==\'o\' || f[si-1]==\'u\') ){\n ans++;\n }\n }\n return ans;\n }\n \n};\n``` | 1 | 0 | ['C++'] | 1 |
count-the-number-of-vowel-strings-in-range | 🔥JAVA || Easy Solution🔥 | java-easy-solution-by-shankarsharma1601-5syp | \uD83D\uDD25\uD83D\uDD25Please Upvote\u2B06\uFE0F and give a \u2B50 if you like the solution. \uD83D\uDD25\uD83D\uDD25\n# Code\n\nclass Solution {\n public i | shankarsharma1601 | NORMAL | 2023-03-16T04:52:07.900756+00:00 | 2023-03-16T04:52:07.900797+00:00 | 61 | false | \uD83D\uDD25\uD83D\uDD25Please Upvote\u2B06\uFE0F and give a \u2B50 if you like the solution. \uD83D\uDD25\uD83D\uDD25\n# Code\n```\nclass Solution {\n public int vowelStrings(String[] words, int left, int right) {\n \n int ans = 0;\n for(int i = left;i<=right;i++){\n String str = words[i];\n char ch1 = str.charAt(0);\n char ch2 = str.charAt(str.length() - 1);\n if( (ch1 == \'a\' || ch1 == \'e\' || ch1 == \'i\' || ch1 == \'o\' || ch1 == \'u\') &&\n (ch2 == \'a\' || ch2 == \'e\' || ch2 == \'i\' || ch2 == \'o\' || ch2 == \'u\') ){\n ans++;\n }\n }\n\n return ans;\n }\n}\n```\n\n\uD83D\uDD25\uD83D\uDD25Please Upvote\u2B06\uFE0F and give a \u2B50 if you like the solution. \uD83D\uDD25\uD83D\uDD25 | 1 | 0 | ['Array', 'String', 'Java'] | 0 |
count-the-number-of-vowel-strings-in-range | C++|| ✅ ✅ easy solution with comment | c-easy-solution-with-comment-by-mac_20-abqz | Intuition\n Describe your first thoughts on how to solve this problem. \n1. We will check word should start and end with vowel(a,e,i,o,u).\n\n# Approach\n Descr | mac_20 | NORMAL | 2023-03-15T18:18:57.153095+00:00 | 2024-03-13T10:26:53.982513+00:00 | 46 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n1. We will check word should start and end with vowel(a,e,i,o,u).\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nTraverse( use for loop) Inclusive of start and end value of integers.\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n O(n)\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nO(1)\n# Code\n```\nclass Solution {\npublic:\n int vowelStrings(vector<string>& words, int left, int right) {\n int count=0;\n for(int i=left;i<=right;i++){\n int n=words[i].size();\n if((words[i][0]==\'a\'|| words[i][0]==\'e\'||words[i][0]==\'i\'||words[i][0]==\'o\'||words[i][0]==\'u\')&&(words[i][n-1]==\'a\'|| words[i][n-1]==\'e\'||words[i][n-1]==\'i\'||words[i][n-1]==\'o\'||words[i][n-1]==\'u\'))\n count++;\n \n \n }\n return count;\n }\n};\n``` | 1 | 0 | ['C'] | 0 |
count-the-number-of-vowel-strings-in-range | Easiest solution ..beats 95%.....very intuitive | easiest-solution-beats-95very-intuitive-w5doe | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\niterate through left position to right position and check each string if | deepanshu03 | NORMAL | 2023-03-15T16:37:45.646356+00:00 | 2023-07-27T19:19:45.855766+00:00 | 116 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\niterate through left position to right position and check each string if it is vowerl string or not\n# Complexity\n- Time complexity:\nworst case time complexity O(n)\n\n- Space complexity:\n Constant O(1)\n\n# Code\n```\nclass Solution {\npublic:\n int vowelStrings(vector<string>& words, int left, int right) {\n int cnt = 0;\n // char list[5] = {\'a\',\'e\',\'i\',\'o\',\'u\'};\n for(int i=left;i<=right;i++){\n char s = words[i][0];\n char e = words[i][words[i].size()-1];\n if(cmp(s) && cmp(e)){\n cnt++;\n }\n \n }\n return cnt;\n }\n\n bool cmp(char a){\n return a==\'a\'|| a==\'e\'||a==\'i\'||a==\'o\'||a==\'u\';\n }\n};\n``` | 1 | 0 | ['C++'] | 0 |
count-the-number-of-vowel-strings-in-range | a joke | a-joke-by-akshat0610-6hpr | Code\n\nclass Solution {\npublic:\n int vowelStrings(vector<string>& words, int left, int right) \n {\n int count = 0;\n for(int i=left;i< | akshat0610 | NORMAL | 2023-03-15T15:34:37.391290+00:00 | 2023-03-15T15:34:37.391337+00:00 | 67 | false | # Code\n```\nclass Solution {\npublic:\n int vowelStrings(vector<string>& words, int left, int right) \n {\n int count = 0;\n for(int i=left;i<=right;i++)\n {\n string word = words[i];\n if(fun(word[0]) == true and fun(word[word.length()-1]) == true)\n {\n count++;\n }\n } \n return count;\n }\n bool fun(char ch)\n {\n if(ch == \'a\') return true;\n if(ch == \'e\') return true;\n if(ch == \'i\') return true;\n if(ch == \'o\') return true;\n if(ch == \'u\') return true;\n\n return false;\n }\n};\n``` | 1 | 0 | ['Array', 'String', 'C++'] | 0 |
count-the-number-of-vowel-strings-in-range | One-linear solution: slice + filter + Set | one-linear-solution-slice-filter-set-by-3uc4l | Code\n\n/**\n * @param {string[]} words\n * @param {number} left\n * @param {number} right\n * @return {number}\n */\nconst vowelCharactersSet = new Set([\'a\', | ods967 | NORMAL | 2023-03-15T13:05:04.195140+00:00 | 2023-03-15T13:05:04.195193+00:00 | 126 | false | # Code\n```\n/**\n * @param {string[]} words\n * @param {number} left\n * @param {number} right\n * @return {number}\n */\nconst vowelCharactersSet = new Set([\'a\', \'e\', \'i\', \'o\', \'u\']);\nvar vowelStrings = function(words, left, right) {\n return words\n .slice(left, right + 1)\n .filter(word => vowelCharactersSet.has(word[0]) && vowelCharactersSet.has(word.at(-1)))\n .length;\n};\n``` | 1 | 0 | ['JavaScript'] | 0 |
count-the-number-of-vowel-strings-in-range | Easy Solution Using For Loop in Python | easy-solution-using-for-loop-in-python-b-5eq3 | \n# Complexity\n- Time complexity: O(n)\n Add your time complexity here, e.g. O(n) \n\n\n# Code\n\nclass Solution:\n def vowelStrings(self, words: List[str], | sanchisinghal | NORMAL | 2023-03-15T10:08:17.610780+00:00 | 2023-03-15T10:08:17.610829+00:00 | 617 | false | \n# Complexity\n- Time complexity: O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n\n# Code\n```\nclass Solution:\n def vowelStrings(self, words: List[str], left: int, right: int) -> int:\n d=["a","e","i","o","u"]\n c=0\n for i in range(left,right+1):\n if(words[i][0] in d and words[i][-1] in d):\n c=c+1\n return c\n``` | 1 | 0 | ['Python3'] | 0 |
count-the-number-of-vowel-strings-in-range | Easy solution using python3 | easy-solution-using-python3-by-chittaran-1ci8 | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | ChittaranjanMore | NORMAL | 2023-03-15T08:09:11.204037+00:00 | 2023-03-15T08:09:11.204084+00:00 | 257 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution:\n def vowelStrings(self, words: List[str], left: int, right: int) -> int:\n vowels = [\'a\', \'e\', \'i\', \'o\', \'u\']\n count = 0\n for i in range(left, right+1):\n if words[i][0] in vowels and words[i][-1] in vowels:\n print(words[i],count)\n count += 1\n\n return count\n``` | 1 | 0 | ['Python3'] | 0 |
count-the-number-of-vowel-strings-in-range | Easy Java Solution || 100 💯 1ms || O(n) | easy-java-solution-100-1ms-on-by-abhinav-4fvi | \n\n# Java Code\n\nclass Solution {\n public int vowelStrings(String[] words, int left, int right) {\n int cnt =0;\n for(int i =left;i<=right;i | abhinavraj126 | NORMAL | 2023-03-15T06:35:15.620955+00:00 | 2023-03-15T06:35:15.621002+00:00 | 19 | false | \n\n# Java Code\n```\nclass Solution {\n public int vowelStrings(String[] words, int left, int right) {\n int cnt =0;\n for(int i =left;i<=right;i++) {\n int n = words[i].length();\n\n if( (words[i].charAt(0)==\'a\' ||\n words[i].charAt(0)==\'e\' ||\n words[i].charAt(0)==\'i\' ||\n words[i].charAt(0)==\'o\' ||\n words[i].charAt(0)==\'u\') &&\n (words[i].charAt(n-1)==\'a\' ||\n words[i].charAt(n-1) ==\'e\' ||\n words[i].charAt(n-1)==\'i\' ||\n words[i].charAt(n-1) ==\'o\' ||\n words[i].charAt(n-1)==\'u\'\n )) {\n cnt++;\n }\n }\n return cnt;\n }\n}\n``` | 1 | 0 | ['Java'] | 0 |
count-the-number-of-vowel-strings-in-range | Count the Number of Vowel Strings in Range | Java | 2ms | Beats 57.60% | count-the-number-of-vowel-strings-in-ran-0zus | Intuition\n Describe your first thoughts on how to solve this problem. \nThe code counts the number of strings within the given range that are vowel strings. A | agarwalmadhur19 | NORMAL | 2023-03-15T03:33:24.365139+00:00 | 2023-03-15T03:33:24.365186+00:00 | 19 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe code counts the number of strings within the given range that are vowel strings. A vowel string is defined as a string where the first and last characters are vowels.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nThe code uses a brute force approach to iterate over each string in the given range and checks if it\'s a vowel string by checking the first and last characters of the string.\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nThe time complexity of the solution is O(n * m), where n is the length of the given range and m is the maximum length of the string in the range. This is because the code iterates over each string in the range and then checks the first and last characters of each string.\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nThe space complexity of the solution is O(1), because the code only uses a constant amount of extra space to store the count variable and the characters of each string while checking for vowels.\n\n# Code\n```\nclass Solution {\n public int vowelStrings(String[] words, int left, int right) {\n int count = 0;\n for(int i = left ; i <= right ; i++)\n {\n if(isVowelString(words[i]))\n {\n count++;\n }\n }\n return count;\n }\n\n private boolean isVowelString(String word)\n {\n char first = word.charAt(0);\n char last = word.charAt(word.length() - 1);\n return isVowel(first) && isVowel(last);\n }\n\n private boolean isVowel(char c)\n {\n return c == \'a\' || c == \'e\' || c == \'i\' || c == \'o\' || c == \'u\';\n }\n}\n``` | 1 | 0 | ['Array', 'String', 'Java'] | 0 |
count-the-number-of-vowel-strings-in-range | Simple java Solution | simple-java-solution-by-c_monish-mada | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | C_Monish | NORMAL | 2023-03-14T13:57:35.205330+00:00 | 2023-03-14T13:57:35.205377+00:00 | 3 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n public int vowelStrings(String[] words, int left, int right) {\n int count=0;\n\t\tfor(int i=left;i<=right;i++) {\n\t\t\tif(words[i].charAt(0)==\'a\' || words[i].charAt(0)==\'e\' ||words[i].charAt(0)==\'i\'||words[i].charAt(0)==\'o\' || words[i].charAt(0)==\'u\') {\n\t\t\t\tif(words[i].charAt(words[i].length()-1)==\'a\' ||words[i].charAt(words[i].length()-1)==\'e\'||words[i].charAt(words[i].length()-1)==\'i\'||words[i].charAt(words[i].length()-1)==\'o\'||words[i].charAt(words[i].length()-1)==\'u\') {\n\t\t\t\t\tcount++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n return count;\n }\n}\n``` | 1 | 0 | ['Java'] | 0 |
count-the-number-of-vowel-strings-in-range | beats 100% | beats-100-by-param161-p4od | Code\n\nclass Solution {\n public static boolean check(int i,int idx,String words[])\n {\n return words[idx].charAt(i)==\'a\' || words[idx].charAt( | param161 | NORMAL | 2023-03-14T13:54:02.139702+00:00 | 2023-03-14T13:54:02.139746+00:00 | 91 | false | # Code\n```\nclass Solution {\n public static boolean check(int i,int idx,String words[])\n {\n return words[idx].charAt(i)==\'a\' || words[idx].charAt(i)==\'e\' || words[idx].charAt(i)==\'i\' || words[idx].charAt(i)==\'u\' || words[idx].charAt(i)==\'o\';\n }\n public int vowelStrings(String[] words, int left, int right) \n {\n int ans=0;\n for(int i=left;i<=right;i++)\n {\n if(check(0,i,words) && check(words[i].length()-1,i,words))\n {\n ans+=1;\n }\n }\n return ans;\n }\n}\n``` | 1 | 0 | ['Java'] | 0 |
count-the-number-of-vowel-strings-in-range | Python and Swift solved | python-and-swift-solved-by-pomgfccdv-u7ho | Code Python one-line version\n\n\n\nclass Solution(object):\n def vowelStrings(self, words, left, right):\n return len([1 for i in range(left, 1 + rig | pomgfccdv | NORMAL | 2023-03-13T17:22:03.592808+00:00 | 2023-03-13T17:22:03.592842+00:00 | 50 | false | # Code Python one-line version\n\n\n```\nclass Solution(object):\n def vowelStrings(self, words, left, right):\n return len([1 for i in range(left, 1 + right) if words[i][0] in \'aeiou\' and words[i][-1] in \'aeiou\'])\n\n\n```\n# Code Python \n\n\n```\nclass Solution:\n def vowelStrings(self, w: List[str], left: int, right: int) -> int:\n vowel = \'aeiou\'\n res = 0\n for i in range(left, 1 + right):\n if w[i][0] in vowel and w[i][-1] in vowel:\n res += 1\n return res\n\n\n```\n# Code Swift\n\n\n```\nclass Solution {\n func vowelStrings(_ w: [String], _ left: Int, _ right: Int) -> Int {\n let vowel: Set<Character> = Set(["a", "e", "i", "o", "u"])\n var res = 0\n for i in left...right {\n if vowel.contains(w[i].first!) && vowel.contains(w[i].last!) {\n res += 1\n }\n }\n return res\n }\n}\n\n\n``` | 1 | 0 | ['String', 'Swift', 'Python', 'Python3'] | 0 |
count-the-number-of-vowel-strings-in-range | Python3|| Beats 100% | python3-beats-100-by-kalyan_2003-n90f | \n\n# Code\n\nclass Solution:\n def vowelStrings(self, words: List[str], left: int, right: int) -> int:\n vowels="aeiou"\n count=0\n for | Kalyan_2003 | NORMAL | 2023-03-13T16:44:49.829870+00:00 | 2023-03-13T16:44:49.829920+00:00 | 44 | false | \n\n# Code\n```\nclass Solution:\n def vowelStrings(self, words: List[str], left: int, right: int) -> int:\n vowels="aeiou"\n count=0\n for i in range(left,right+1):\n if words[i][0] in vowels and words[i][-1] in vowels:\n count+=1\n return count\n```\n# Please upvote if you find the solution helpful. | 1 | 0 | ['Python3'] | 1 |
count-the-number-of-vowel-strings-in-range | [Accepted] Swift | accepted-swift-by-vasilisiniak-d2fh | \nclass Solution {\n func vowelStrings(_ words: [String], _ left: Int, _ right: Int) -> Int {\n (left...right)\n .map { words[$0] }\n | vasilisiniak | NORMAL | 2023-03-12T14:51:43.142354+00:00 | 2023-03-12T14:51:43.142384+00:00 | 23 | false | ```\nclass Solution {\n func vowelStrings(_ words: [String], _ left: Int, _ right: Int) -> Int {\n (left...right)\n .map { words[$0] }\n .filter { "aeiou".contains($0.first!) && "aeiou".contains($0.last!) }\n .count\n }\n}\n``` | 1 | 0 | ['Swift'] | 0 |
count-the-number-of-vowel-strings-in-range | Easy C++ Solution | easy-c-solution-by-haribhakt-nce0 | Intuition\n\n# Approach\n\n# Complexity\n- Time complexity: O(n) \n\n- Space complexity: O(1)\n\n# Code\n\nclass Solution {\nprivate:\n bool checkVowel(char | HariBhakt | NORMAL | 2023-03-12T12:22:53.105236+00:00 | 2023-03-12T12:22:53.105263+00:00 | 105 | false | # Intuition\n\n# Approach\n\n# Complexity\n- Time complexity: $$O(n)$$ \n\n- Space complexity: $$O(1)$$\n\n# Code\n```\nclass Solution {\nprivate:\n bool checkVowel(char c){\n return (c ==\'a\' || c==\'e\' || c==\'i\' || c==\'o\' || c==\'u\');\n }\npublic:\n int vowelStrings(vector<string>& words, int left, int right) {\n int ans = 0;\n for(int i=left;i<=right;i++){\n string temp = words[i];\n if(checkVowel(temp.front()) && checkVowel(temp.back())) ans++;\n }\n return ans;\n }\n};\n``` | 1 | 0 | ['C++'] | 0 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | [Java/C++/Python] O(1) Solution | javacpython-o1-solution-by-lee215-iapp | Intuition\nWe will increment a times to a + 1,\nand then copy b timees to sum,\nso that (a + 1) * (b + 1) >= k.\n\nSo the question is:\nFind min(a + b), so that | lee215 | NORMAL | 2024-03-24T04:04:31.680405+00:00 | 2024-03-24T04:29:12.042871+00:00 | 4,574 | false | # **Intuition**\nWe will increment `a` times to `a + 1`,\nand then copy `b` timees to sum,\nso that `(a + 1) * (b + 1) >= k`.\n\nSo the question is:\nFind `min(a + b)`, so that `(a + 1) * (b + 1) >= k`.\n<br>\n\n# **Intuition 2**\nFor same value of `a + b`,\nto make `ab` biggest,\nwe need to make `a == b`.\nSo if `a == b`, `(b + 1) * (b + 1) >= k`\nSo if `a == b + 1`, `a * (a + 1) >= k`.\n<br>\n\n# **Explanation**\n`int a = sqrt(k)`.\nif `a * a == k`, then return `a + a - 2`\nif `a * (a + 1) >= k`, then return `a + a - 1`\nif `(a + 1) * (a + 1) >= k`, then return `a + a`\n<br>\n\n# **Explanation 2**\n`b = ceil(k / a)`\nwith interger division:, `b = (k - 1) / a + 1`\nthen we return `a + b - 2`\n<br>\n\n# **Complexity**\nTime `O(sqrt)`\nSpace `O(sqrt)`\n<br>\n\n**Java**\n```java\n public int minOperations(int k) {\n int a = (int) Math.sqrt(k);\n return a + (k - 1) / a - 1;\n }\n```\n\n**C++**\n```cpp\n int minOperations(int k) {\n int a = sqrt(k);\n return a + (k - 1) / a - 1;\n }\n```\n\n**Python**\n```py\n def minOperations(self, k: int) -> int:\n v = isqrt(k)\n return v + (k - 1) // v - 1\n```\n | 47 | 2 | ['C', 'Python', 'Java'] | 20 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | SQRT vs. Binary Search | sqrt-vs-binary-search-by-votrubac-amyc | The best strategy is:\n - Increase first element from 1 to m.\n - Duplicate elements (k - 1) / m times.\n - It is counter-productive to increase any elemen | votrubac | NORMAL | 2024-03-24T04:02:46.044408+00:00 | 2024-03-27T22:28:36.184296+00:00 | 2,395 | false | The best strategy is:\n - Increase first element from 1 to `m`.\n - Duplicate elements `(k - 1) / m` times.\n - It is counter-productive to increase any elements after we start duplicating.\n\nWe can find the best `m` using brute-force.\n \nIt is not hard to see, however, that `m` is the smallest value such as `m * m >= k`.\n\n> For more intuition, see the alternative solution below.\n \n**C++**\n```cpp\nint minOperations(int k) {\n int m = ceil(sqrt(k));\n return m - 1 + (k - 1) / m;\n}\n```\n\n### Binary Search\nFor a number `i`, we can precompute the largest `k` we can achieve as `(i - i / 2 + 1) * (i / 2 + 1)`.\n\nThen, we can binary-search our `dp` array to get the smallest `i` to cover `k`.\n\n**C++**\n```cpp\nconstexpr static auto dp = [](array<int, 632> v = {}) {\n for (int i = 0; i < v.size(); ++i)\n v[i] = (i - i / 2 + 1) * (i / 2 + 1);\n return v;\n}();\nint minOperations(int k) {\n return lower_bound(begin(dp), end(dp), k) - begin(dp);\n}\n``` | 30 | 1 | [] | 15 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | Step-Step Easy Video Solution🔥 || Maths ✅ || Greedy | step-step-easy-video-solution-maths-gree-o5v2 | Intuition\n Describe your first thoughts on how to solve this problem. \nTry with all inputs\n\n# Easy Video Explanation\nhttps://youtu.be/XSIunvB3UQg\n\n\n\n\n | ayushnemmaniwar12 | NORMAL | 2024-03-24T04:05:42.465321+00:00 | 2024-03-24T06:19:08.551231+00:00 | 1,769 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nTry with all inputs\n\n# ***Easy Video Explanation***\nhttps://youtu.be/XSIunvB3UQg\n\n\n\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n O(N)\n \n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n O(1)\n \n\n# Code\n\n\n```C++ []\nclass Solution {\npublic:\n int minOperations(int k) {\n int minOperationsNeeded = INT_MAX;\n for(int operations = 1; operations <= k; operations++) {\n int groups = ceil(k / (operations * 1.0));\n minOperationsNeeded = min(minOperationsNeeded, operations - 2 + groups);\n }\n return minOperationsNeeded;\n }\n};\n\n```\n```python []\nimport math\n\nclass Solution:\n def minOperations(self, k: int) -> int:\n ans = math.inf\n for i in range(1, k + 1):\n m = math.ceil(k / i)\n ans = min(ans, i - 2 + m)\n return ans\n\n```\n```Java []\npublic class Solution {\n public int minOperations(int k) {\n int ans = Integer.MAX_VALUE;\n for (int i = 1; i <= k; i++) {\n int m = (int) Math.ceil(k / (double) i);\n ans = Math.min(ans, i - 2 + m);\n }\n return ans;\n }\n}\n\n\n```\n\n# ***If you like the solution Please Upvote and subscribe to my youtube channel***\n***It Motivates me to record more videos***\n\n*Thank you* \uD83D\uDE00 | 21 | 0 | ['Math', 'Python', 'C++', 'Java'] | 2 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | Explained - O(1) & O(N) || First increment and then duplicate || Simple and easy solution | explained-o1-on-first-increment-and-then-93vm | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach 1 : O(N) solution\n- We can think to increase the value from 1 to i in (i | kreakEmp | NORMAL | 2024-03-24T04:08:57.382853+00:00 | 2024-03-24T08:03:48.696422+00:00 | 3,198 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach 1 : O(N) solution\n- We can think to increase the value from 1 to i in (i - 1) steps, then duplicate this i by ceil(k/i) - 1 number of times. \n- Take min possible count for all value of i \n\n# Code\n```\nint minOperations(int k) {\n if(k == 1) return 0;\n int ans = k;\n for(int i = 1; i <= k/2; ++i){\n int t = (i - 1) + (ceil((double)k/(double)i) - 1);\n ans = min(ans, t);\n }\n return ans;\n}\n```\n\n# Approach 2 : O(1) solution\n\n- In the last approach we are keep on checking all possible values where the multiplication of i and (k/i) value will lead to a value greater than or equal to k.\n- To get optimal value of a & b where a*b = k, a should be equal to b as per max/min derivative \n- so as i = k/i => i = sqrt(k). We need to take ceil as we need a value greater than k and don\'t want to truncate the decimal values.\n- Now we need i - 1 times addition = sqrt(k) - 1 times and ceil(k/ sqrt(k)) - 1 times replication.\n\n```\nint minOperations(int k) {\n int sq = ceil(sqrt(k));\n return (sq - 1) + ceil((double)k/sq) - 1;\n}\n```\n\n\n\n---\n\n<b> Here is an article of my last interview experience - A Journey to FAANG Company, I recomand you to go through this to know which all resources I have used & how I cracked interview at Amazon:\nhttps://leetcode.com/discuss/interview-experience/3171859/Journey-to-a-FAANG-Company-Amazon-or-SDE2-(L5)-or-Bangalore-or-Oct-2022-Accepted\n\n--- | 13 | 3 | ['C++'] | 6 |
apply-operations-to-make-sum-of-array-greater-than-or-equal-to-k | Simple java solution | simple-java-solution-by-siddhant_1602-sivx | Complexity\n- Time complexity: O(n)\n\n- Space complexity: O(1)\n\n# Code\n\nclass Solution {\n public int minOperations(int k) {\n if(k==1)\n | Siddhant_1602 | NORMAL | 2024-03-24T04:01:35.288590+00:00 | 2024-03-24T04:01:35.288625+00:00 | 460 | false | # Complexity\n- Time complexity: $$O(n)$$\n\n- Space complexity: $$O(1)$$\n\n# Code\n```\nclass Solution {\n public int minOperations(int k) {\n if(k==1)\n {\n return 0;\n }\n int ans=k;\n for(int i=2;i<=k;i++)\n {\n int val=i-1;\n if(k%i==0)\n {\n val+=k/i-1;\n }\n else\n {\n val+=k/i;\n }\n ans=Math.min(ans,val);\n }\n return ans;\n }\n}\n``` | 11 | 0 | ['Java'] | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.