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
maximum-candies-allocated-to-k-children
Binary Search, C++ With Explanation ✅✅
binary-search-c-with-explanation-by-deep-3j1t
\n# Approach\n Describe your approach to solving the problem. \nHere i apply Binary Search Algorithm to find out Maximum Number of candies.\n\nMaximum Number of
Deepak_5910
NORMAL
2023-06-05T16:45:51.170565+00:00
2023-06-05T16:47:29.299886+00:00
129
false
\n# Approach\n<!-- Describe your approach to solving the problem. -->\nHere i apply **Binary Search Algorithm** to find out Maximum Number of candies.\n\nMaximum Number of Candies Always Belong to range **[1 , Maximum of array]** , number of Maximum Candies can be any Element from this sorted array that satisfy the giv...
2
0
['Binary Search', 'C++']
0
maximum-candies-allocated-to-k-children
using binary search on answer , explanation
using-binary-search-on-answer-explanatio-e3jt
instead of applying binary search directly on array we will apply binary search on the range of the answer.\n\nlow = 1 because there can be minimum 1 candy in t
AbhayDutt
NORMAL
2023-04-01T09:55:27.451852+00:00
2023-04-01T09:55:27.451892+00:00
983
false
instead of applying binary search directly on array we will apply binary search on the range of the answer.\n\nlow = 1 because there can be minimum 1 candy in the array\nhigh = maximum in the array because that is the maaximum amount of candies that can be present in the pile\n\n\nnow we want to validate each mid that ...
2
0
['Binary Search', 'Java']
1
maximum-candies-allocated-to-k-children
C++ || Binary Search on Search Space || Easy Solution
c-binary-search-on-search-space-easy-sol-6npp
Time Complexity : O(n*logm) , where m is the maximum number of candies in the single pile.\n\nclass Solution {\nprivate:\n bool isValid(vector<int>& candies,
aniketk2k
NORMAL
2023-03-08T10:45:20.341807+00:00
2023-03-08T11:32:47.681824+00:00
872
false
**Time Complexity : O(n*logm)** , where m is the maximum number of candies in the single pile.\n```\nclass Solution {\nprivate:\n bool isValid(vector<int>& candies, long long k, int max_candies){\n long long child_cnt = 0;\n \n for(auto candies: candies)\n child_cnt += candies/max_can...
2
0
['C', 'Binary Tree', 'C++']
1
maximum-candies-allocated-to-k-children
✅✅Easy Java code|| Beats 99%||✅✅
easy-java-code-beats-99-by-princebharti-zfmp
\n# Approach\n Describe your approach to solving the problem. \nFirst find the range of candies to be distributed then,\nUse Binary Search to find the maximum n
PRINCEBharti
NORMAL
2023-03-07T14:55:04.602965+00:00
2023-03-07T14:55:04.603011+00:00
566
false
\n# Approach\n<!-- Describe your approach to solving the problem. -->\nFirst find the range of candies to be distributed then,\nUse Binary Search to find the maximum number of candies distributed.\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n$$O(nlogn)$$\n- Space complexit...
2
0
['Java']
0
maximum-candies-allocated-to-k-children
Java Sol || Easy || Binary Search || Simple
java-sol-easy-binary-search-simple-by-hi-d2ru
Code\n\nclass Solution {\n public int maximumCandies(int[] candies, long k) {\n int low = 1;\n int high = Arrays.stream(candies).max().getAsInt
himanshu_gupta_
NORMAL
2023-02-07T20:45:06.704385+00:00
2023-02-07T20:45:06.704412+00:00
624
false
# Code\n```\nclass Solution {\n public int maximumCandies(int[] candies, long k) {\n int low = 1;\n int high = Arrays.stream(candies).max().getAsInt();\n int ans = 0;\n while (low<=high) {\n int mid = low + (high-low)/2;\n long currAns = 0;\n for (int i : ...
2
0
['Java']
0
maximum-candies-allocated-to-k-children
Binary Search method
binary-search-method-by-optimal_ns65-3v91
class Solution {\npublic:\n bool allocation(vector& candies,long long k,long long mid){\n if(mid==0) return true;\n \n long long q=0;\n
Optimal_NS65
NORMAL
2022-04-03T18:29:07.665170+00:00
2022-04-03T18:29:07.665219+00:00
24
false
class Solution {\npublic:\n bool allocation(vector<int>& candies,long long k,long long mid){\n if(mid==0) return true;\n \n long long q=0;\n long long count=0;\n for(int i=0;i<candies.size();i++){\n int q=candies[i]/mid;\n count+=q;\n if(count>=k){...
2
0
[]
0
maximum-candies-allocated-to-k-children
C++ | Simple Binary Search Solution O(n*log(max(candies)))
c-simple-binary-search-solution-onlogmax-xcre
\nclass Solution {\npublic:\n bool check(vector<int>& arr,int mid, long long k){\n long long count = 0;\n for(int i : arr){\n count
LastStyleBender
NORMAL
2022-04-03T16:13:07.879198+00:00
2022-04-03T16:13:07.879243+00:00
74
false
```\nclass Solution {\npublic:\n bool check(vector<int>& arr,int mid, long long k){\n long long count = 0;\n for(int i : arr){\n count += (i/mid);\n }\n \n return (count >= k);\n }\n \n int maximumCandies(vector<int>& arr, long long k) {\n int lo = 1, hi ...
2
0
['C', 'Binary Tree']
1
maximum-candies-allocated-to-k-children
C++ || Binary Search
c-binary-search-by-kr_sk_01_in-u8z5
\n bool is_possible(vector<int>& candies, int mid, long long k)\n {\n long long count = 0;\n \n for(int i = 0; i < candies.size(); i++)
KR_SK_01_In
NORMAL
2022-04-03T07:27:30.530943+00:00
2022-04-03T07:27:30.530972+00:00
160
false
```\n bool is_possible(vector<int>& candies, int mid, long long k)\n {\n long long count = 0;\n \n for(int i = 0; i < candies.size(); i++)\n {\n count += candies[i] / mid;\n }\n \n if(count >= k)\n return true;\n \n return false;\n...
2
0
['C', 'Binary Tree', 'C++']
0
maximum-candies-allocated-to-k-children
C++ Binary Search Solution
c-binary-search-solution-by-mayanksamadh-2bno
Please Upvote If It Helps\n\nclass Solution {\npublic:\n bool valid(int mid,vector<int>& candies,long long k)\n {\n // it will containg the count t
mayanksamadhiya12345
NORMAL
2022-04-03T06:41:35.741340+00:00
2022-04-03T06:42:00.450260+00:00
56
false
**Please Upvote If It Helps**\n```\nclass Solution {\npublic:\n bool valid(int mid,vector<int>& candies,long long k)\n {\n // it will containg the count that will tell we can assign or not assign candies to children \n long sum = 0;\n for(auto it : candies)\n {\n sum += (it/...
2
0
[]
0
maximum-candies-allocated-to-k-children
Java | Binary Search | Easy To Understand
java-binary-search-easy-to-understand-by-zrap
Here I am discussing my approach to this problem\nApproach:\n1. First calculate total number of candies. Let it be sum.\n2. If sum < k, return 0 we have more ch
SudhanshuMallick
NORMAL
2022-04-03T04:17:21.909428+00:00
2022-04-03T04:17:21.909472+00:00
181
false
**Here I am discussing my approach to this problem**\n**Approach:**\n1. First calculate **total number** of candies. Let it be `sum`.\n2. If `sum < k`, **return 0** we have **more children than candies**.\n3. If `sum = k`, **return 1** as we have** as many children as candies**.\n4. Else, perform **binary search** on *...
2
0
['Binary Tree', 'Java']
0
maximum-candies-allocated-to-k-children
🎁C++ Binary Search Easy Explaination Code
c-binary-search-easy-explaination-code-b-6hnt
\n\nclass Solution\n{\npublic:\n long long int maxPiles(vector<int> candies, long long int k)\n {\n long long int l = 1; // We can select an minimu
omhardaha1
NORMAL
2022-04-03T04:13:28.672021+00:00
2022-04-03T04:15:57.211359+00:00
66
false
```\n\nclass Solution\n{\npublic:\n long long int maxPiles(vector<int> candies, long long int k)\n {\n long long int l = 1; // We can select an minimum 1 element\n long long int h = 0;\n for (auto i : candies)\n {\n h += i;\n }\n if (k > h)\n {\n ...
2
0
['C', 'Binary Tree', 'C++']
0
maximum-candies-allocated-to-k-children
[CPP] Binary Search || Easy to Understand
cpp-binary-search-easy-to-understand-by-74725
\nclass Solution {\npublic:\n //checks if each children can get C candies\n bool isPossible(vector<int>& candies, long long C, long long k) {\n lon
arsator
NORMAL
2022-04-03T04:02:04.812294+00:00
2022-04-03T04:02:04.812341+00:00
67
false
```\nclass Solution {\npublic:\n //checks if each children can get C candies\n bool isPossible(vector<int>& candies, long long C, long long k) {\n long long cnt = 0;\n for(auto c : candies) {\n cnt += (long long)(c/C);\n }\n \n return cnt >= k;\n }\n \n //Bin...
2
0
[]
0
maximum-candies-allocated-to-k-children
🧠 Greedy Candy Splitting: The Binary Search Trick Everyone Misses!
greedy-candy-splitting-the-binary-search-yqp6
IntuitionWe want to split piles of candies into exactly k children — each getting the maximum equal amount possible. Trying all possible values is too slow. But
loginov-kirill
NORMAL
2025-03-30T07:01:14.353214+00:00
2025-04-01T18:55:04.384759+00:00
1,140
false
### Intuition We want to split piles of candies into exactly `k` children — each getting the **maximum equal amount possible**. Trying all possible values is too slow. But what if we reverse the problem and ask: **“Can we give each child `x` candies?”** This naturally leads us to **binary search**! --- ### Ap...
1
0
['Array', 'Math', 'Binary Search', 'Heap (Priority Queue)', 'Python', 'JavaScript']
1
count-prefixes-of-a-given-string
[Java/C++/Python] Starts With
javacpython-starts-with-by-lee215-lw6y
Explanation\nfor each word w in words list,\ncheck if word w startsWith the string s\n\n\n# Complexity\nTime O(NS)\nSpace O(1)\n\n\nJava\njava\n public int c
lee215
NORMAL
2022-04-30T16:16:13.275791+00:00
2022-05-03T06:43:22.216403+00:00
6,395
false
# **Explanation**\nfor each word `w` in `words` list,\ncheck if word `w` `startsWith` the string `s`\n<br>\n\n# **Complexity**\nTime `O(NS)`\nSpace `O(1)`\n<br>\n\n**Java**\n```java\n public int countPrefixes(String[] words, String s) {\n int res = 0;\n for (String w : words)\n if (s.startsW...
46
0
['C', 'Python', 'Java']
12
count-prefixes-of-a-given-string
C++ || Easy O(NxS) solution || String
c-easy-onxs-solution-string-by-yash2arma-3lb0
\nclass Solution {\npublic:\n //iterate over each words[i] and take the sub-string str from s of size equals to words[i].\n //and compare str with words[i
Yash2arma
NORMAL
2022-04-30T16:13:17.949594+00:00
2022-05-01T07:29:15.665748+00:00
2,487
false
```\nclass Solution {\npublic:\n //iterate over each words[i] and take the sub-string str from s of size equals to words[i].\n //and compare str with words[i] if both are equal increase count by 1.\n int countPrefixes(vector<string>& words, string s) \n {\n int count=0;\n for(auto it: words)\n...
28
0
['String', 'C', 'Iterator', 'C++']
3
count-prefixes-of-a-given-string
Java 1-Liner
java-1-liner-by-fllght-z8l9
java\npublic int countPrefixes(String[] words, String s) {\n return (int) Arrays.stream(words).filter(s::startsWith).count();\n }\n\n\nMy repositories
FLlGHT
NORMAL
2022-05-01T08:12:39.278135+00:00
2023-05-12T05:22:01.753813+00:00
1,724
false
```java\npublic int countPrefixes(String[] words, String s) {\n return (int) Arrays.stream(words).filter(s::startsWith).count();\n }\n```\n\nMy repositories with leetcode problems solving - [Java](https://github.com/FLlGHT/algorithms/tree/master/j-algorithms/src/main/java), [C++](https://github.com/FLlGHT/al...
27
0
['Java']
1
count-prefixes-of-a-given-string
Easy python solution
easy-python-solution-by-tusharkhanna575-rxrk
\nclass Solution:\n def countPrefixes(self, words: List[str], s: str) -> int:\n count=0\n for i in words:\n if (s[:len(i)]==i):\n
tusharkhanna575
NORMAL
2022-05-26T14:42:38.412749+00:00
2022-05-26T14:42:38.412777+00:00
1,521
false
```\nclass Solution:\n def countPrefixes(self, words: List[str], s: str) -> int:\n count=0\n for i in words:\n if (s[:len(i)]==i):\n count+=1\n return count\n```
15
0
['Python', 'Python3']
1
count-prefixes-of-a-given-string
C++ || EASY TO UNDERSTAND || Simple Solution
c-easy-to-understand-simple-solution-by-drkqu
\nclass Solution {\npublic:\n int countPrefixes(vector<string>& words, string s) \n {\n int counter = 0;\n \n for(int i=0;i<words.siz
mayanksamadhiya12345
NORMAL
2022-04-30T16:10:41.260290+00:00
2022-05-01T16:15:53.055127+00:00
1,085
false
```\nclass Solution {\npublic:\n int countPrefixes(vector<string>& words, string s) \n {\n int counter = 0;\n \n for(int i=0;i<words.size();i++)\n {\n if(words[i] == s.substr(0,words[i].size())) \n counter++;\n }\n\n return counter;\n }\n};\n...
11
0
[]
2
count-prefixes-of-a-given-string
count_if
count_if-by-votrubac-cb8s
C++\ncpp\nint countPrefixes(vector<string>& words, string s) {\n return count_if(begin(words), end(words), [&](const auto &w){ return s.compare(0, w.size(),
votrubac
NORMAL
2022-05-01T22:06:35.443879+00:00
2022-05-03T03:55:36.094024+00:00
798
false
**C++**\n```cpp\nint countPrefixes(vector<string>& words, string s) {\n return count_if(begin(words), end(words), [&](const auto &w){ return s.compare(0, w.size(), w) == 0; });\n}\n```
8
0
['C']
3
count-prefixes-of-a-given-string
Python simple solution
python-simple-solution-by-tovam-xyjb
Approach\nCheck for each word if is prefix of s.\n\n# Code\n\nclass Solution:\n def countPrefixes(self, words: List[str], s: str) -> int:\n res = 0\n\
TovAm
NORMAL
2023-01-05T15:28:38.090957+00:00
2023-01-05T15:28:38.090995+00:00
1,139
false
# Approach\nCheck for each word if is prefix of s.\n\n# Code\n```\nclass Solution:\n def countPrefixes(self, words: List[str], s: str) -> int:\n res = 0\n\n for word in words:\n if s.startswith(word):\n res += 1\n\n return res\n```\n\nLike it? Please upvote!
7
0
['Python3']
1
count-prefixes-of-a-given-string
Java Easy to Understand Solution
java-easy-to-understand-solution-by-janh-wflx
\nclass Solution {\n public int countPrefixes(String[] words, String s) {\n \n int result = 0;\n for (int i=0; i<=s.length(); i++) {
Janhvi__28
NORMAL
2022-10-20T18:06:56.439131+00:00
2022-10-20T18:06:56.439175+00:00
814
false
```\nclass Solution {\n public int countPrefixes(String[] words, String s) {\n \n int result = 0;\n for (int i=0; i<=s.length(); i++) {\n String x = s.substring(0, i);\n for (int j = 0; j<words.length; j++) {\n if (x.equals(words[j]))\n ...
7
0
['Java']
0
count-prefixes-of-a-given-string
✅✅✅Straightforward Javascript Solution || Faster than 96.67%
straightforward-javascript-solution-fast-95qp
\nvar countPrefixes = function(words, s) {\n let count = 0;\n for (let word of words) {\n if (s.startsWith(word)) count++\n } return count;\n};\
a-fr0stbite
NORMAL
2022-05-28T17:24:05.888742+00:00
2022-08-02T00:42:34.923627+00:00
459
false
```\nvar countPrefixes = function(words, s) {\n let count = 0;\n for (let word of words) {\n if (s.startsWith(word)) count++\n } return count;\n};\n```\n![image](https://assets.leetcode.com/users/images/9ebdaad0-0ac6-40e8-98da-26c37a70fab5_1653758537.70002.png)\n
7
0
['JavaScript']
1
count-prefixes-of-a-given-string
✅ 2 Lines || C++ / java
2-lines-c-java-by-xxvvpp-g6gk
Apply find() in case of c++ and indexof() in case of java on every word and check if return position is 0.\nReturn the count of such strings.\n# C++\n int co
xxvvpp
NORMAL
2022-04-30T16:15:05.509693+00:00
2022-04-30T16:21:12.974176+00:00
975
false
Apply **find()** in case of c++ and **indexof()** in case of java on every word and check if return position is 0.\nReturn the count of such strings.\n# C++\n int countPrefixes(vector<string>& words, string s, int cnt=0){\n for(auto i:words) if(s.find(i)==0) cnt++;\n return cnt;\n }\n\t\n# Java\n ...
7
0
['C', 'Java']
3
count-prefixes-of-a-given-string
C++ || Basic string understanding
c-basic-string-understanding-by-shm_47-4r2k
\nclass Solution {\npublic:\n int countPrefixes(vector<string>& words, string s) {\n int cnt = 0;\n int i, j;\n for(i=0; i<words.size();
shm_47
NORMAL
2022-04-30T16:11:13.336732+00:00
2022-04-30T16:11:13.336771+00:00
555
false
```\nclass Solution {\npublic:\n int countPrefixes(vector<string>& words, string s) {\n int cnt = 0;\n int i, j;\n for(i=0; i<words.size(); i++){\n j = 0;\n while(j< words[i].size()){\n if(words[i][j] != s[j])\n break;\n j++;...
7
0
['C']
0
count-prefixes-of-a-given-string
C++ Easy Solution using Only One For loop and One If Condition
c-easy-solution-using-only-one-for-loop-djv3c
Intuition\nThe intuition for the problem is to iterate through each word in the words array, extract a substring from s that matches the length of the word, and
_sxrthakk
NORMAL
2024-06-29T12:16:30.243764+00:00
2024-06-29T12:16:30.243794+00:00
280
false
# Intuition\nThe intuition for the problem is to iterate through each word in the words array, extract a substring from s that matches the length of the word, and compare it with the word itself. Increment a counter each time a match is found, returning the final count of matching prefixes.\n\n# Approach\n**Initialize ...
6
0
['String', 'C++']
1
count-prefixes-of-a-given-string
3 different fastest approaches with javascript - including one-liner
3-different-fastest-approaches-with-java-6yk0
// approach 1 \n\n\nvar countPrefixes = function(words, s) {\n let counter = 0\n for (let i = 0; i < words.length; i++) {\n if (words[i]) === s.
Apoorv-123
NORMAL
2022-08-22T00:15:17.242709+00:00
2022-08-22T00:22:25.549321+00:00
679
false
// approach 1 \n\n```\nvar countPrefixes = function(words, s) {\n let counter = 0\n for (let i = 0; i < words.length; i++) {\n if (words[i]) === s.slice(0,words[i].length)) {\n counter++\n }\n }\n return counter\n};\n```\n\n// one liner approach - 2\n\n```\nvar countPrefixes = f...
6
0
['JavaScript']
1
count-prefixes-of-a-given-string
JS easiest way
js-easiest-way-by-andrezzz-acee
\nvar countPrefixes = function(words, s) {\n \n let cont = 0;\n \n for(i = 0; i < words.length; i++){\n for(j = 1; j <= s.length; j++){\n
andrezzz
NORMAL
2022-05-04T18:10:02.585610+00:00
2022-05-04T18:10:02.585649+00:00
547
false
```\nvar countPrefixes = function(words, s) {\n \n let cont = 0;\n \n for(i = 0; i < words.length; i++){\n for(j = 1; j <= s.length; j++){\n if(words[i] == s.slice(0, j)){\n cont++;\n }\n } \n }\n return cont;\n \n};\n```
6
0
['JavaScript']
0
count-prefixes-of-a-given-string
Python straightforward with startswith.
python-straightforward-with-startswith-b-uw5f
\ndef countPrefixes(self, words: List[str], s: str) -> int:\n\n c = 0\n for w in words:\n if s.startswith(w):\n c += 1\n\n return c\n
vineeth_moturu
NORMAL
2022-04-30T16:08:57.925966+00:00
2022-04-30T16:08:57.926001+00:00
588
false
```\ndef countPrefixes(self, words: List[str], s: str) -> int:\n\n c = 0\n for w in words:\n if s.startswith(w):\n c += 1\n\n return c\n```
6
0
['Python']
3
count-prefixes-of-a-given-string
Beats 100% of users with C++ || Step By Step Explain || Easy to Understand ||
beats-100-of-users-with-c-step-by-step-e-bcxc
Abhiraj Pratap Singh\n\n---\n\n# if you like the solution please UPVOTE it....\n\n---\n\n# Intuition\n Describe your first thoughts on how to solve this problem
abhirajpratapsingh
NORMAL
2024-02-05T15:29:05.835690+00:00
2024-02-05T15:29:05.835725+00:00
229
false
# Abhiraj Pratap Singh\n\n---\n\n# if you like the solution please UPVOTE it....\n\n---\n\n# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n- The problem involves counting the number of words in a vector that have a specific prefix equal to a given string s.\n\n---\n\n![Screenshot (47)....
5
0
['Array', 'String', 'String Matching', 'C++']
1
count-prefixes-of-a-given-string
Java || 100% beats || 2 solutions || ❤️❤️
java-100-beats-2-solutions-by-saurabh_ku-kjc1
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
saurabh_kumar1
NORMAL
2023-08-24T18:56:09.555301+00:00
2023-08-24T18:56:09.555328+00:00
479
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:0(N)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:0(1)\n<!-- Add your space complexity here, e.g. $$O...
5
0
['String', 'String Matching', 'Java']
0
count-prefixes-of-a-given-string
C++ | 3-Line solution
c-3-line-solution-by-vartika2207-wlj1
\tclass Solution {\n\tpublic:\n\t\t//time:O(n), space: O(1)\n\t\tint countPrefixes(vector& words, string s) {\n\t\t\tint count = 0;\n\t\t\tfor(auto wd : words)\
vartika2207
NORMAL
2022-11-30T22:07:23.519381+00:00
2022-11-30T22:07:23.519415+00:00
697
false
\tclass Solution {\n\tpublic:\n\t\t//time:O(n), space: O(1)\n\t\tint countPrefixes(vector<string>& words, string s) {\n\t\t\tint count = 0;\n\t\t\tfor(auto wd : words)\n\t\t\t\tif(s.find(wd) < 1) count++; //if first occurrence of sub-string is in the specified string\n\t\t\treturn count;\n\t\t}\n\t};
5
0
['C', 'C++']
2
count-prefixes-of-a-given-string
C++ Simple Solution using substr()
c-simple-solution-using-substr-by-prasad-uxjd
\nclass Solution {\npublic:\n int countPrefixes(vector<string>& words, string s) {\n int n = words.size();\n int cnt = 0;\n for(int i=0;
Prasad264
NORMAL
2022-04-30T16:35:11.347911+00:00
2022-04-30T16:35:11.347949+00:00
426
false
```\nclass Solution {\npublic:\n int countPrefixes(vector<string>& words, string s) {\n int n = words.size();\n int cnt = 0;\n for(int i=0; i<n; i++) {\n string str = words[i];\n if(str == s.substr(0, str.size())) cnt++;\n }\n return cnt;\n }\n};\n```
5
0
['String', 'C']
3
count-prefixes-of-a-given-string
Java || Easy Appraoch
java-easy-appraoch-by-ashwinj_984-orxi
\nclass Solution {\n public int countPrefixes(String[] words, String s) {\n int i = 0;\n int j = 0;\n int count = 0;\n for(int k
ashwinj_984
NORMAL
2022-04-30T16:08:54.194604+00:00
2022-04-30T16:08:54.194656+00:00
768
false
```\nclass Solution {\n public int countPrefixes(String[] words, String s) {\n int i = 0;\n int j = 0;\n int count = 0;\n for(int k = 0; k < words.length; k++){\n if(words[k].length() > s.length()){\n continue;\n }\n \n while(i < ...
5
0
['String', 'Java']
0
count-prefixes-of-a-given-string
Best Solution Using set || Easy to Understand
best-solution-using-set-easy-to-understa-d8fu
Approach\nStep 1 : Define a map and empty stirng\nStep2 : insert prefixes in map\nStep3 : check how many array of words element is present in map\n\n\n\nclass S
ParthBabbar
NORMAL
2022-04-30T16:06:30.606400+00:00
2022-04-30T16:15:36.091331+00:00
283
false
Approach\nStep 1 : Define a map and empty stirng\nStep2 : insert prefixes in map\nStep3 : check how many array of words element is present in map\n\n\n```\nclass Solution {\npublic:\n int countPrefixes(vector<string>& words, string s) {\n unordered_set<string> mp;\n string st = "";\n for(int i=0...
5
0
['String', 'C']
0
count-prefixes-of-a-given-string
python3 code
python3-code-by-blackhole_tiub-c62q
Code\n\nclass Solution:\n def countPrefixes(self, words: List[str], s: str) -> int:\n return len([word for word in words if s.startswith(word)])\n\n\n
Little_Tiub
NORMAL
2022-12-28T23:53:42.204520+00:00
2023-05-02T05:51:06.502800+00:00
271
false
# Code\n```\nclass Solution:\n def countPrefixes(self, words: List[str], s: str) -> int:\n return len([word for word in words if s.startswith(word)])\n```\n\n![image.png](https://assets.leetcode.com/users/images/7ded423d-5651-41aa-8a7e-b8343efb856e_1672271463.1473987.png)\n![image.png](https://assets.leetcode...
4
1
['Python3']
0
count-prefixes-of-a-given-string
1 line of code🔥100% faster code 🔥Beginner friendly🔥
1-line-of-code100-faster-code-beginner-f-2vf7
Please UPVOTE if helps.\n# Complexity\n- Time complexity: O(n^2)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(1)\n Add your space comple
diyordev
NORMAL
2023-12-07T16:10:53.721069+00:00
2023-12-07T16:10:53.721101+00:00
191
false
# Please UPVOTE if helps.\n# Complexity\n- Time complexity: $$O(n^2)$$\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 countPrefixes(String[] words, String s) {;\n int c...
3
0
['Java']
0
count-prefixes-of-a-given-string
Java Solution|| Beats 100%💯 || 3 line code🔥
java-solution-beats-100-3-line-code-by-v-cqx1
\n# Approach\n Describe your approach to solving the problem. \n- The startsWith method returns true if the string it is called on starts with the provided pref
Vishu6403
NORMAL
2023-10-09T09:11:03.521445+00:00
2023-10-09T09:11:03.521471+00:00
151
false
\n# Approach\n<!-- Describe your approach to solving the problem. -->\n- The startsWith method returns true if the string it is called on starts with the provided prefix (string s), otherwise it returns false.\n\n# Complexity\n- Time complexity:$$O(n)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space ...
3
0
['Array', 'String', 'Java']
1
count-prefixes-of-a-given-string
one line solution
one-line-solution-by-yuliia_anatoliivna-nvsv
\n\n# Code\n\nclass Solution:\n def countPrefixes(self, words: List[str], s: str) -> int:\n return sum(1 for x in words if s.startswith(x))\n
Yuliia_Anatoliivna
NORMAL
2023-05-31T17:17:11.986423+00:00
2023-05-31T17:17:11.986471+00:00
298
false
\n\n# Code\n```\nclass Solution:\n def countPrefixes(self, words: List[str], s: str) -> int:\n return sum(1 for x in words if s.startswith(x))\n```
3
0
['Python3']
1
count-prefixes-of-a-given-string
Simple | Easy | (100%) JAVA Solution
simple-easy-100-java-solution-by-pranavi-cwy0
\n\nclass Solution {\n public int countPrefixes(String[] words, String s) {\n int count=0;\n for(String word: words){\n if(s.startsW
pranavibhute
NORMAL
2023-05-17T12:05:54.210279+00:00
2023-05-17T13:13:31.425017+00:00
558
false
\n```\nclass Solution {\n public int countPrefixes(String[] words, String s) {\n int count=0;\n for(String word: words){\n if(s.startsWith(word)) count++;\n }\n return count;\n }\n}\n```
3
0
['String', 'Counting', 'Java']
0
count-prefixes-of-a-given-string
Simple Using Substr | C++
simple-using-substr-c-by-mankaran_07-g3ym
Please Upvote If you Like the Solution !!!\n# Code\n\nclass Solution {\npublic:\n int countPrefixes(vector<string>& words, string s) {\n int ans = 0;\
mankaran_07
NORMAL
2023-04-22T10:16:10.736757+00:00
2023-04-22T10:16:10.736804+00:00
400
false
`Please Upvote If you Like the Solution !!!`\n# Code\n```\nclass Solution {\npublic:\n int countPrefixes(vector<string>& words, string s) {\n int ans = 0;\n for(auto &w : words) {\n int n = w.size();\n if(s.substr(0,n) == w) ans++;\n }\n return ans;\n }\n};\n```
3
0
['C++']
0
count-prefixes-of-a-given-string
✅ Easy and Fast C++ Solution
easy-and-fast-c-solution-by-adarsh_shukl-1kdx
Approach\nUsing s.find(words[i]) function which returns the index of words[i] if it is present in the string s , and to check whether words[i] occurs as a prefi
Adarsh_Shukla
NORMAL
2022-12-22T12:55:35.040102+00:00
2022-12-22T12:56:40.386175+00:00
605
false
# Approach\nUsing **s.find(words[i])** function which returns the index of words[i] if it is present in the string s , and to check whether words[i] occurs as a prefix use **s.find(words[i])==0** ( since prefix always occurs at index 0).\n\n# Code\n```\nclass Solution {\npublic:\n int countPrefixes(vector<string>& ...
3
0
['C++']
1
count-prefixes-of-a-given-string
Easy O(N) | Maintain a Set
easy-on-maintain-a-set-by-vkadu68-klwj
We maintian a set called seen and add all the prefixes in the set and then simply check if the word in word list is present in the set or not\n\nLeave an upvote
vkadu68
NORMAL
2022-11-01T21:29:24.471481+00:00
2022-11-01T21:29:24.471515+00:00
388
false
We maintian a set called seen and add all the prefixes in the set and then simply check if the word in word list is present in the set or not\n\n***Leave an upvote if this helps!!!***\n```\nclass Solution:\n def countPrefixes(self, words: List[str], s: str) -> int:\n seen=set()\n count=0\n for i...
3
0
['Ordered Set', 'Python']
0
count-prefixes-of-a-given-string
Easy Python solution
easy-python-solution-by-vistrit-igdd
\ndef countPrefixes(self, words: List[str], s: str) -> int:\n c=0\n for i in words:\n l=len(i)\n if i==s[:l]:\n
vistrit
NORMAL
2022-05-17T18:53:59.607539+00:00
2022-05-17T18:53:59.607581+00:00
389
false
```\ndef countPrefixes(self, words: List[str], s: str) -> int:\n c=0\n for i in words:\n l=len(i)\n if i==s[:l]:\n c+=1\n return c\n```
3
0
['Python', 'Python3']
0
count-prefixes-of-a-given-string
C++ online with std::count_if and string::rfind
c-online-with-stdcount_if-and-stringrfin-jv4m
This stackover flow post descrives how to you string::rfind to implement startsWith, which leads to following over all code to solve to problem.\n\n\nint countP
heder
NORMAL
2022-04-30T18:26:54.995781+00:00
2022-08-10T18:24:35.411643+00:00
93
false
This [stackover flow post](https://stackoverflow.com/questions/1878001/how-do-i-check-if-a-c-stdstring-starts-with-a-certain-string-and-convert-a) descrives how to you ```string::rfind``` to implement ```startsWith```, which leads to following over all code to solve to problem.\n\n```\nint countPrefixes(const vector<st...
3
0
['C']
0
count-prefixes-of-a-given-string
C++ || 5 Lines Code || Very Easy O(N) Solution
c-5-lines-code-very-easy-on-solution-by-cwkyx
\nint countPrefixes(vector<string>& words, string s) {\n int c=0;\n for(string str:words){\n int len=str.length();\n string sub
Gagan-Chaudhary
NORMAL
2022-04-30T17:53:41.019322+00:00
2022-04-30T17:53:41.019365+00:00
130
false
```\nint countPrefixes(vector<string>& words, string s) {\n int c=0;\n for(string str:words){\n int len=str.length();\n string subs=s.substr(0,len);\n if(str==subs){\n c++;\n }\n } \n return c;\n }\n```
3
0
['String', 'C', 'Iterator', 'C++']
1
count-prefixes-of-a-given-string
java
java-by-sakshi2602-c4cs
int ans=0;\n HashMap l=new HashMap<>();\n for(String str:words)\n l.put(str,l.getOrDefault(str,0)+1);\n for(int i=0;i<=s.length(
sakshi2602
NORMAL
2022-04-30T16:13:44.527942+00:00
2022-04-30T16:15:48.564339+00:00
288
false
int ans=0;\n HashMap<String,Integer> l=new HashMap<>();\n for(String str:words)\n l.put(str,l.getOrDefault(str,0)+1);\n for(int i=0;i<=s.length();i++)\n {\n String st=s.substring(0,i);\n if(l.containsKey(st))\n ans=ans+l.get(st);\n }\n ...
3
0
['Java']
0
count-prefixes-of-a-given-string
C++ || EASY TO UNDERSTAND || Simple Solution
c-easy-to-understand-simple-solution-by-xz3qm
\nclass Solution {\npublic:\n int countPrefixes(vector<string>& words, string s) {\n int c=0;\n for(auto word:words)\n {\n
aarindey
NORMAL
2022-04-30T16:02:53.460367+00:00
2022-04-30T16:02:53.460401+00:00
135
false
```\nclass Solution {\npublic:\n int countPrefixes(vector<string>& words, string s) {\n int c=0;\n for(auto word:words)\n {\n string str=word;\n int l=word.size();\n string s2=s.substr(0,l);\n if(s2==word)\n c++;\n ...
3
1
[]
0
count-prefixes-of-a-given-string
7 Liner javaScript Easy Solution
7-liner-javascript-easy-solution-by-ali-6tsvl
Code\njavascript []\n/**\n * @param {string[]} words\n * @param {string} s\n * @return {number}\n */\nvar countPrefixes = function (words, s) {\n let count = 0
ALI-786
NORMAL
2024-08-27T12:29:58.729179+00:00
2024-08-27T12:29:58.729206+00:00
49
false
# Code\n```javascript []\n/**\n * @param {string[]} words\n * @param {string} s\n * @return {number}\n */\nvar countPrefixes = function (words, s) {\n let count = 0;\n for (let i = 0; i < words.length; i++) {\n if (s.startsWith(words[i])) {\n count++;\n }\n }\n return count;\n};\n```
2
0
['JavaScript']
0
count-prefixes-of-a-given-string
simplest one PYTHON
simplest-one-python-by-justingeorge-2hv1
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-05T08:18:29.839533+00:00
2024-03-05T08:18:29.839560+00:00
216
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)$$ --...
2
0
['Python3']
0
count-prefixes-of-a-given-string
Very easy logic , for beginners !!
very-easy-logic-for-beginners-by-user120-2rdh
Intuition\nInitialize a variable count to store the count of prefixes found in the string s.\nIterate through each word in the words array.\nFor each word encou
user1203oJ
NORMAL
2024-02-24T06:22:53.272079+00:00
2024-02-24T06:22:53.272139+00:00
520
false
# Intuition\nInitialize a variable count to store the count of prefixes found in the string s.\nIterate through each word in the words array.\nFor each word encountered, check if the string s starts with that word using the startsWith method.\nIf the word is found to be a prefix of s, increment the count.\nAfter iterat...
2
0
['Java']
0
count-prefixes-of-a-given-string
Simple Solution
simple-solution-by-anshika_73-tgte
\n\n# Code\n\nclass Solution {\npublic:\n int countPrefixes(vector<string>& words, string s) {\n int count =0;\n for(auto str : words){\n
Anshika_73_
NORMAL
2023-12-04T13:21:28.114548+00:00
2023-12-04T13:21:28.114588+00:00
92
false
\n\n# Code\n```\nclass Solution {\npublic:\n int countPrefixes(vector<string>& words, string s) {\n int count =0;\n for(auto str : words){\n int len = str.length();\n auto subs = s.substr(0,len);\n if(str == subs){\n count++;\n }\n }\n ...
2
0
['C++']
2
count-prefixes-of-a-given-string
Easy one-liner C#
easy-one-liner-c-by-rxcore-v57d
\n# Approach\nUsing Count and StartsWith\n\n# Code\n\npublic class Solution {\n public int CountPrefixes(string[] words, string s) {\n return words.Co
rxcore
NORMAL
2023-09-26T17:11:18.965491+00:00
2023-09-26T17:11:18.965518+00:00
38
false
\n# Approach\nUsing Count and StartsWith\n\n# Code\n```\npublic class Solution {\n public int CountPrefixes(string[] words, string s) {\n return words.Count(i => s.StartsWith(i));\n }\n}\n```
2
0
['C#']
0
count-prefixes-of-a-given-string
Javascript easy one line solution
javascript-easy-one-line-solution-by-bri-5ylw
Complexity\n- Time complexity: O(n*m)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(n)\n Add your space complexity here, e.g. O(n) \n\n#
brijesh178
NORMAL
2023-08-28T16:53:55.875454+00:00
2023-08-28T16:53:55.875475+00:00
209
false
# Complexity\n- Time complexity: O(n*m)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(n)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\n/**\n * @param {string[]} words\n * @param {string} s\n * @return {number}\n */\nvar countPrefixes = function (words, s) {\n ...
2
0
['JavaScript']
0
count-prefixes-of-a-given-string
Go easy
go-easy-by-ganesh_raveendran-kw1n
\n\n# Code\n\nfunc countPrefixes(words []string, s string) int {\n\tvar count int\n\n\tfor _, v := range words {\n\t\tif strings.HasPrefix(s, v) {\n\t\t\tcount+
ganesh_raveendran
NORMAL
2023-08-16T11:56:07.177539+00:00
2023-08-16T11:56:07.177556+00:00
16
false
\n\n# Code\n```\nfunc countPrefixes(words []string, s string) int {\n\tvar count int\n\n\tfor _, v := range words {\n\t\tif strings.HasPrefix(s, v) {\n\t\t\tcount++\n\t\t}\n\t}\n\n\treturn count\n}\n```
2
0
['Go']
0
count-prefixes-of-a-given-string
Python one line solution
python-one-line-solution-by-azazellooo-blf6
\n\n# Code\n\nclass Solution:\n def countPrefixes(self, words: List[str], s: str) -> int:\n return len([i for i in words if s.startswith(i)])\n
azazellooo
NORMAL
2023-07-28T07:01:57.409952+00:00
2023-07-28T07:01:57.409975+00:00
205
false
\n\n# Code\n```\nclass Solution:\n def countPrefixes(self, words: List[str], s: str) -> int:\n return len([i for i in words if s.startswith(i)])\n```
2
0
['Python3']
0
count-prefixes-of-a-given-string
Easy to understand
easy-to-understand-by-bhaskarkumar07-wius
\n\n# Approach\n Describe your approach to solving the problem. \n if it starts with element present in array count++;\n# Complexity\n- Time complexity:O
bhaskarkumar07
NORMAL
2023-04-24T15:26:33.969584+00:00
2023-04-24T15:26:33.969610+00:00
690
false
\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n if it starts with element present in array count++;\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...
2
0
['Java']
0
count-prefixes-of-a-given-string
simple java 3 line code
simple-java-3-line-code-by-bhupendra0820-j0pm
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
bhupendra082002
NORMAL
2023-03-31T16:28:23.926044+00:00
2023-03-31T16:28:23.926078+00:00
311
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)$$ --...
2
0
['Java']
0
count-prefixes-of-a-given-string
Esay Java Solution
esay-java-solution-by-md_ashik786-epfi
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
MD_Ashik786
NORMAL
2023-03-25T01:52:40.291810+00:00
2023-03-25T01:52:40.291850+00:00
593
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)$$ --...
2
0
['Java']
0
count-prefixes-of-a-given-string
C++ || Easy || Simple
c-easy-simple-by-naoman-l9zb
\n\n# Code\n\nclass Solution {\npublic:\n int countPrefixes(vector<string>& words, string s) {\n int count = 0;\n for (string word : words)\n
Naoman
NORMAL
2023-03-10T05:38:08.079838+00:00
2023-03-10T05:38:08.079884+00:00
725
false
\n\n# Code\n```\nclass Solution {\npublic:\n int countPrefixes(vector<string>& words, string s) {\n int count = 0;\n for (string word : words)\n {\n if(s.find(word) == 0) \n { \n count++;\n }\n }\n return count;\n }\n};\n\n```
2
0
['C++']
0
count-prefixes-of-a-given-string
Pyhton3 oneliner using startswith()
pyhton3-oneliner-using-startswith-by-ami-hnjc
\n\n# Code\n\nclass Solution:\n def countPrefixes(self, words: List[str], s: str) -> int:\n count = 0\n for i in words:\n if s.start
amitpandit03
NORMAL
2023-03-03T01:46:14.379198+00:00
2023-03-03T01:46:14.379236+00:00
59
false
\n\n# Code\n```\nclass Solution:\n def countPrefixes(self, words: List[str], s: str) -> int:\n count = 0\n for i in words:\n if s.startswith(i):\n count += 1\n return count\n\n #One Liner\n\n return sum(1 for i in words if s.startswith(i))\n```
2
0
['Python3']
0
count-prefixes-of-a-given-string
✔Simple C++ code || Easy || beats 100% ✌
simple-c-code-easy-beats-100-by-kraken_0-8ae4
\n\nRuntime: Beats 100%\n\n# Code\n\nclass Solution {\npublic:\n int countPrefixes(vector<string>& words, string s) {\n int c=0;\n for(auto j:w
Kraken_02
NORMAL
2023-02-12T16:02:40.108526+00:00
2023-02-12T16:02:40.108564+00:00
545
false
\n\nRuntime: Beats 100%\n\n# Code\n```\nclass Solution {\npublic:\n int countPrefixes(vector<string>& words, string s) {\n int c=0;\n for(auto j:words){\n int b=1;\n for(int i=0;i<j.size();i++){\n if(j[i]!=s[i]){\n b=0;\n break;...
2
0
['C++']
0
count-prefixes-of-a-given-string
Pooping solution :)
pooping-solution-by-kaushikp0908-tlra
Approach\n Describe your approach to solving the problem. \nPoop the loop\n\n# Complexity\n- Time complexity: O(N)\n Add your time complexity here, e.g. O(n) \n
kaushikp0908
NORMAL
2023-02-06T07:16:53.484396+00:00
2023-02-06T07:16:53.484436+00:00
152
false
# Approach\n<!-- Describe your approach to solving the problem. -->\nPoop the loop\n\n# Complexity\n- Time complexity: O(N)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\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 countPrefixes(...
2
0
['Python3']
0
count-prefixes-of-a-given-string
Easy solution
easy-solution-by-shubhanjalisingh_001-o4nk
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
ShubhanjaliSingh_001
NORMAL
2022-12-02T04:38:44.407793+00:00
2022-12-02T04:38:44.407830+00:00
307
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)$$ --...
2
0
['C++']
0
count-prefixes-of-a-given-string
C++|| Easy Approach || 93% Faster
c-easy-approach-93-faster-by-spects-acul-jdd8
\nclass Solution {\npublic:\n int countPrefixes(vector<string>& words, string s) { \n int ans = 0;\n for(int i = 0 ; i<words.size() ; i++){\n
spects-acular
NORMAL
2022-10-14T06:51:36.663268+00:00
2022-10-14T06:51:36.663310+00:00
309
false
```\nclass Solution {\npublic:\n int countPrefixes(vector<string>& words, string s) { \n int ans = 0;\n for(int i = 0 ; i<words.size() ; i++){\n string element = words[i];\n int len = element.length();\n \n for(int j = 0 ; j<len ; j++){\n \n ...
2
0
[]
1
count-prefixes-of-a-given-string
✅ 'startsWith()' in Java | Java
startswith-in-java-java-by-sayakmondal-5z5x
\nif(you like)\n\tplease upvote;\n\n\n\n# Java Code\n\nclass Solution {\n public int countPrefixes(String[] words, String s) {\n int cnt = 0;\n
Sayakmondal
NORMAL
2022-10-02T16:18:18.031088+00:00
2022-10-02T16:23:48.320824+00:00
311
false
```\nif(you like)\n\tplease upvote;\n```\n![image.png](https://assets.leetcode.com/users/images/c46bfd5c-cd60-4a0f-a3af-d56e67ae236a_1664727810.0896583.png)\n\n# Java Code\n```\nclass Solution {\n public int countPrefixes(String[] words, String s) {\n int cnt = 0;\n for(String str:words) \n ...
2
0
['String', 'Java']
0
count-prefixes-of-a-given-string
python solution
python-solution-by-dugu0607-mfk9
\tclass Solution:\n\t\tdef countPrefixes(self, words: List[str], s: str) -> int:\n\t\t\tres = 0\n\t\t\tfor word in words:\n\t\t\t\tif s[:len(word)] == word: res
Dugu0607
NORMAL
2022-10-02T06:20:02.825221+00:00
2022-10-02T06:20:02.825265+00:00
371
false
\tclass Solution:\n\t\tdef countPrefixes(self, words: List[str], s: str) -> int:\n\t\t\tres = 0\n\t\t\tfor word in words:\n\t\t\t\tif s[:len(word)] == word: res += 1\n\t\t\treturn res
2
0
[]
0
count-prefixes-of-a-given-string
python ||O(N)
python-on-by-sneh713-aiva
Time Complexcity O(N)\nspace Complexcity O(1)\n\nclass Solution:\n def countPrefixes(self, words: List[str], s: str) -> int:\n count=0\n for wo
Sneh713
NORMAL
2022-09-26T12:53:29.158577+00:00
2022-09-26T12:53:29.158614+00:00
905
false
Time Complexcity O(N)\nspace Complexcity O(1)\n```\nclass Solution:\n def countPrefixes(self, words: List[str], s: str) -> int:\n count=0\n for word in words:\n n=len(word)\n if s[0:n]==word:\n count+=1\n return count\n \n```
2
0
['String', 'Python3']
1
count-prefixes-of-a-given-string
Python straight forward one-liner
python-straight-forward-one-liner-by-trp-k5e4
Here is what I did:\n\npython\n def countPrefixes(self, words: List[str], s: str) -> int:\n return sum(s.startswith(word) for word in words)\n
trpaslik
NORMAL
2022-09-12T10:52:52.174389+00:00
2022-09-12T10:52:52.174434+00:00
330
false
Here is what I did:\n\n```python\n def countPrefixes(self, words: List[str], s: str) -> int:\n return sum(s.startswith(word) for word in words)\n```
2
0
['Python']
1
count-prefixes-of-a-given-string
✅ [JavaScript] Straightforward Solution || Simple & Understandable || Fast
javascript-straightforward-solution-simp-wt1s
Runtime: 68 ms, faster than 91.85% of JavaScript online submissions for Count Prefixes of a Given String.\nMemory Usage: 43 MB, less than 40.00% of JavaScript o
PoeticIvy302543
NORMAL
2022-07-03T00:48:15.488151+00:00
2022-07-25T21:32:49.484404+00:00
121
false
**Runtime: 68 ms, faster than 91.85% of JavaScript online submissions for Count Prefixes of a Given String.\nMemory Usage: 43 MB, less than 40.00% of JavaScript online submissions for Count Prefixes of a Given String.**\n\n```\nvar countPrefixes = function(words, s) {\n let count = 0\n for (i of words) {\n ...
2
0
['String', 'JavaScript']
0
count-prefixes-of-a-given-string
C# LINQ One-line
c-linq-one-line-by-aip-s5vd
\n\tpublic int CountPrefixes(string[] words, string s) \n => words.Count(w => s.StartsWith(w)); \n
AIP
NORMAL
2022-05-04T08:59:50.653397+00:00
2022-05-04T08:59:50.653429+00:00
76
false
```\n\tpublic int CountPrefixes(string[] words, string s) \n => words.Count(w => s.StartsWith(w)); \n```
2
0
[]
0
count-prefixes-of-a-given-string
Rust solutions
rust-solutions-by-bigmih-3tuw
Simle use of starts_with:\n\nimpl Solution {\n pub fn count_prefixes(words: Vec<String>, s: String) -> i32 {\n words.iter().filter(|w| s.starts_with(w
BigMih
NORMAL
2022-05-01T09:25:16.219701+00:00
2022-05-01T09:25:16.219732+00:00
64
false
1. Simle use of `starts_with`:\n```\nimpl Solution {\n pub fn count_prefixes(words: Vec<String>, s: String) -> i32 {\n words.iter().filter(|w| s.starts_with(w.as_str())).count() as _\n }\n}\n```\n2. Slice comparison\n```\nimpl Solution {\n pub fn count_prefixes(words: Vec<String>, s: String) -> i32 {\n ...
2
0
['Rust']
0
count-prefixes-of-a-given-string
Go golang solution
go-golang-solution-by-leaf_peng-rxt2
go\nfunc countPrefixes(words []string, s string) int {\n ans := 0\n for _, word := range words {\n n := len(word)\n if n > len(s) { continue
leaf_peng
NORMAL
2022-05-01T01:08:25.469918+00:00
2022-05-01T01:08:50.166341+00:00
73
false
```go\nfunc countPrefixes(words []string, s string) int {\n ans := 0\n for _, word := range words {\n n := len(word)\n if n > len(s) { continue }\n if word == s[:n] { ans++ }\n }\n return ans\n}\n```
2
0
['Go']
0
count-prefixes-of-a-given-string
C++ very easy to Understand | solution using unordered set
c-very-easy-to-understand-solution-using-du23
```\nclass Solution {\npublic:\n int countPrefixes(vector& words, string s) {\n unordered_set st;\n int size = s.size();\n for(int i = 0
Ashishks0211
NORMAL
2022-04-30T18:46:16.772904+00:00
2022-04-30T18:46:16.772935+00:00
55
false
```\nclass Solution {\npublic:\n int countPrefixes(vector<string>& words, string s) {\n unordered_set<string> st;\n int size = s.size();\n for(int i = 0;i<size;i++){\n string temp = "";\n for(int j = 0;j<=i;j++){\n temp+=s[j];\n }\n st.i...
2
0
['C']
0
count-prefixes-of-a-given-string
📌 [JAVA] | Simple
java-simple-by-kanojiyakaran-y91t
```\nclass Solution {\n public int countPrefixes(String[] words, String s) {\n \n int preFixCount=0;\n for(String curr:words){\n int
kanojiyakaran
NORMAL
2022-04-30T16:00:56.377246+00:00
2022-04-30T16:03:22.896520+00:00
345
false
```\nclass Solution {\n public int countPrefixes(String[] words, String s) {\n \n int preFixCount=0;\n for(String curr:words){\n int i=0;\n \n if(curr.length()>s.length()) // if current string length greater than s length invalid prefix\n continue; \n ...
2
0
['Java']
0
count-prefixes-of-a-given-string
Optimized Set-Based Solution | O(n + m) Time | Python 3
optimized-set-based-solution-on-m-time-p-hkk1
IntuitionWe need to count how many words in words are prefixes of the string s. A prefix is any substring that starts from the beginning of s. Instead of checki
NRSingh
NORMAL
2025-04-03T19:23:59.393721+00:00
2025-04-03T19:23:59.393721+00:00
19
false
# Intuition We need to count how many words in words are prefixes of the string s. A prefix is any substring that starts from the beginning of s. Instead of checking each word against s directly (which would be inefficient), we can precompute all valid prefixes of s and store them in a set for quick lookup. <!-- Descri...
1
0
['Array', 'String', 'Python3']
0
count-prefixes-of-a-given-string
Count Prefixes of a Given String (Optimal Approach)
count-prefixes-of-a-given-string-optimal-mi26
IntuitionApproachGo through the array and check if the each element starting matches the prefix word.Complexity Time complexity: O(n) Space complexity: O(1)Code
Vinil07
NORMAL
2025-04-01T05:22:03.798635+00:00
2025-04-01T05:22:03.798635+00:00
19
false
# Intuition <!-- Describe your first thoughts on how to solve this problem. --> # Approach <!-- Describe your approach to solving the problem. --> Go through the array and check if the each element starting matches the prefix word. # Complexity - Time complexity: <!-- Add your time complexity here, e.g. $$O(n)$$ --> ...
1
0
['Array', 'String', 'C++']
0
count-prefixes-of-a-given-string
0MS || Beats 100% || Easy and Simple Java Solution
0ms-beats-100-easy-and-simple-java-solut-g2d7
🔍 Intuition: We need to count how many strings in thewordsarray areprefixesof strings. Aprefixmeans the string appears at thebeginningofs. Example Understanding
Yashvendra
NORMAL
2025-02-20T16:13:35.467778+00:00
2025-02-20T16:13:35.467778+00:00
100
false
## 🔍 Intuition: - We need to count how many strings in the `words` array are **prefixes** of string `s`. - A **prefix** means the string appears at the **beginning** of `s`. - **Example Understanding:** - **Input:** `words = ["a", "b", "ab", "abc"]`, `s = "abc"` - `"a"`, `"ab"`, and `"abc"` are **prefixes** of `...
1
0
['Array', 'String', 'Java']
0
count-prefixes-of-a-given-string
0ms, Beats 100%, Hopefully my solution will help everyone with an easy problem solving
0ms-beats-100-hopefully-my-solution-will-vn5n
IntuitionApproachComplexity Time complexity:O(n) Space complexity:O(1) Code
bvc01654
NORMAL
2025-02-05T08:58:45.397939+00:00
2025-02-05T08:58:45.397939+00:00
66
false
# Intuition <!-- Describe your first thoughts on how to solve this problem. --> # Approach <!-- Describe your approach to solving the problem. --> # 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)$$ --> ...
1
0
['String', 'Iterator', 'C++']
0
count-prefixes-of-a-given-string
[C++] Simple Solution
c-simple-solution-by-samuel3shin-8lai
Code
Samuel3Shin
NORMAL
2025-01-23T16:11:58.057030+00:00
2025-01-23T16:11:58.057030+00:00
35
false
# Code ```cpp [] class Solution { public: int countPrefixes(vector<string>& words, string s) { unordered_set<string> hs; for(int i=1; i<=s.size(); i++) { hs.insert(s.substr(0, i)); } int ans = 0; for(auto w : words) { if(hs.count(w)) ans++; } ...
1
0
['C++']
0
count-prefixes-of-a-given-string
0MS 🥇|| BEATS 100% 🥂 || 5 LINE CODE ⛳ || 🌟JAVA ☕
0ms-beats-100-5-line-code-java-by-galani-giph
Code
Galani_jenis
NORMAL
2025-01-18T05:30:24.151194+00:00
2025-01-18T05:30:24.151194+00:00
88
false
![Screenshot 2025-01-11 154428.png](https://assets.leetcode.com/users/images/f03b73f2-83d3-4e96-b4fb-bc566f531f16_1737178088.854509.png) # Code ```java [] class Solution { public int countPrefixes(String[] words, String s) { int ans = 0; for (String word : words) { if (s.startsWith(wo...
1
0
['Java']
0
count-prefixes-of-a-given-string
4 lines of python code beats 100%
4-lines-of-python-code-beats-100-by-vsab-mr5x
IntuitionApproachComplexity Time complexity: Space complexity: Code
vsabari146
NORMAL
2025-01-10T07:35:59.463227+00:00
2025-01-10T07:35:59.463227+00:00
113
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 `...
1
0
['Python3']
0
count-prefixes-of-a-given-string
Easy solution for begineers || 100%
easy-solution-for-begineers-100-by-kunal-lzjm
IntuitionApproachComplexity Time complexity: Space complexity: Code
kunal44885
NORMAL
2025-01-09T15:03:26.643077+00:00
2025-01-09T15:03:26.643077+00:00
112
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 `...
1
0
['C++']
0
count-prefixes-of-a-given-string
Built-in Function
built-in-function-by-khushi_1502-7kuc
Complexity Time complexity:O(N) Space complexity:O(1) Code
khushi_1502
NORMAL
2025-01-09T06:42:51.795312+00:00
2025-01-09T06:42:51.795312+00:00
124
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 countPrefixes(String[] words, String s) { int count=0; for(int i=0;i<words.length;...
1
0
['Java']
0
count-prefixes-of-a-given-string
🔍 Count Prefixes in a String – Clean and Concise Python Solution!🚀
count-prefixes-in-a-string-clean-and-con-whmg
🧠 Intuition💡 The task is to count how many words in the list words are prefixes of the string s. A word is a prefix of s if it matches the initial characters of
Ramanand98
NORMAL
2025-01-09T06:32:51.300285+00:00
2025-01-09T06:32:51.300285+00:00
95
false
![image.png](https://assets.leetcode.com/users/images/dd38a7eb-9c88-4ea0-8600-d38945a43464_1736404286.578581.png) # 🧠 **Intuition** 💡 The task is to count how many words in the list `words` are prefixes of the string `s`. - A word is a prefix of `s` if it matches the initial characters of `s`. - We can check...
1
0
['Python3']
0
count-prefixes-of-a-given-string
Easy Solution | Beat 100% | c++ Solution
easy-solution-beat-100-c-solution-by-nit-5pl7
IntuitionThe problem asks us to count how many words in the given list words are prefixes of the string s. The simplest approach is to check each word in the li
NITian_Dilip
NORMAL
2025-01-09T05:41:53.359594+00:00
2025-01-09T05:45:54.721417+00:00
82
false
# Intuition The problem asks us to count how many words in the given list `words` are prefixes of the string `s`. The simplest approach is to check each word in the list and see if it matches the prefix of `s`. If the word is a prefix, we increment the count. --- # Approach 1. **Initialize a count variable** to k...
1
0
['Array', 'String', 'String Matching', 'C++']
0
count-prefixes-of-a-given-string
2255. Count Prefixes of a Given String
2255-count-prefixes-of-a-given-string-by-ky4l
Complexity Time complexity: O(M*N) Space complexity: O(1) Code
Adarshjha
NORMAL
2025-01-09T05:16:29.130771+00:00
2025-01-09T05:16:29.130771+00:00
7
false
# Complexity - Time complexity: O(M*N) <!-- Add your time complexity here, e.g. $$O(n)$$ --> - Space complexity: O(1) <!-- Add your space complexity here, e.g. $$O(n)$$ --> # Code ```c [] int countPrefixes(char** words, int wordsSize, char* s) { int t, count = 0; for (int i = 0; i < wordsSize; i++) { ...
1
0
['C']
0
count-prefixes-of-a-given-string
Easy solution with explanation beats 100%
easy-solution-with-explanation-beats-100-3u05
IntuitionThe goal is to count how many words in the array words are prefixes of the string s. The Java String class provides the startsWith() method, which make
Shubhash_Singh
NORMAL
2025-01-09T04:24:21.809558+00:00
2025-01-09T04:24:21.809558+00:00
21
false
# Intuition The goal is to count how many words in the array `words` are prefixes of the string `s`. The Java String class provides the `startsWith()` method, which makes it straightforward to check if one string is a prefix of another. # Approach 1. Iterate Through the Words: Loop through each word in the words array...
1
0
['Java']
0
count-prefixes-of-a-given-string
🔥BEATS 💯 % 🎯 |✨SUPER EASY FOR BEGINNERS 👏
beats-super-easy-for-beginners-by-vignes-z7nb
Code
vigneshvaran0101
NORMAL
2025-01-09T04:00:08.915637+00:00
2025-01-09T04:00:08.915637+00:00
40
false
![image.png](https://assets.leetcode.com/users/images/8eded86b-3f70-4b20-9d18-c8d23e539b1e_1736395174.2889311.png) # Code ```python3 [] class Solution: def countPrefixes(self, words: List[str], s: str) -> int: c = 0 for i in words: if s.startswith(i): c += 1 ...
1
0
['Python3']
0
count-prefixes-of-a-given-string
ads;
ads-by-abhaydeep_24-b04j
Complexity Time complexity: O(N*M) N=size of words array M=max length of word in words array Space complexity: O(1) Code
abhaydeep_24
NORMAL
2025-01-09T01:25:47.749151+00:00
2025-01-09T01:25:47.749151+00:00
30
false
![image.png](https://assets.leetcode.com/users/images/2c97a7a0-0106-48ad-b16b-41297a3d5b48_1736385846.3465495.png) # Complexity - Time complexity: O(N*M) N=size of words array M=max length of word in words array <!-- Add your time complexity here, e.g. $$O(n)$$ --> - Space complexity: O(1) <!-- Add your space complex...
1
0
['C++']
0
count-prefixes-of-a-given-string
Simplest answer in 1 loop
simplest-answer-in-1-loop-by-saksham_gup-a8bs
Complexity Time complexity: O(n.m) (n for strings in array and m for length of each string) Space complexity: O(1) Code
Saksham_Gupta_
NORMAL
2025-01-04T11:19:52.844737+00:00
2025-01-04T11:19:52.844737+00:00
116
false
<!-- Describe your approach to solving the problem. --> # Complexity - Time complexity: ***O(n.m)*** *(n for strings in array and m for length of each string)* <!-- Add your time complexity here, e.g. $$O(n)$$ --> - Space complexity: ***O(1)*** <!-- Add your space complexity here, e.g. $$O(n)$$ --> # Code ```java [...
1
0
['Array', 'String', 'Java']
0
count-prefixes-of-a-given-string
leetcodedaybyday - Beats 100% with C++ and Beats 100% with Python3
leetcodedaybyday-beats-100-with-c-and-be-3j3i
IntuitionThe task is to count how many words in the words list are prefixes of the string s. A prefix of a string is defined as a substring that starts at the b
tuanlong1106
NORMAL
2024-12-28T08:31:04.567395+00:00
2024-12-28T08:31:04.567395+00:00
82
false
# Intuition The task is to count how many words in the `words` list are prefixes of the string `s`. A prefix of a string is defined as a substring that starts at the beginning of the string. To solve this, we can compare each word in the `words` list with the corresponding prefix of `s` of the same length. # Approach ...
1
0
['Array', 'String', 'C++', 'Python3']
0
count-prefixes-of-a-given-string
Easy and 100% fast solution using string method
easy-and-100-fast-solution-using-string-qmloz
IntuitionTo solve the problem of finding how many strings in the words array are a prefix of string s, let us break this problem :- Understanding a Prefix :-
code_space
NORMAL
2024-12-17T09:33:19.897625+00:00
2024-12-17T09:33:19.897625+00:00
142
false
![image.png](https://assets.leetcode.com/users/images/efecd940-e574-42ad-8225-84689f70f6c2_1734427968.1863089.png)\n\n# Intuition\nTo solve the problem of finding how many strings in the `words` array are a prefix of string `s`, let us break this problem :-\n1. **Understanding a Prefix** :- A string w is said to be a ...
1
0
['Array', 'String', 'C++', 'Java', 'JavaScript']
0
count-prefixes-of-a-given-string
Count Prefixes of a Given String
count-prefixes-of-a-given-string-by-tejd-3o8v
Intuition\n Describe your first thoughts on how to solve this problem. \nThe problem is to determine how many strings in an array are prefixes of a given string
tejdekiwadiya
NORMAL
2024-06-12T17:21:54.940920+00:00
2024-06-12T17:21:54.940943+00:00
21
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe problem is to determine how many strings in an array are prefixes of a given string. A prefix of a string is a substring that starts at the beginning of the string and can be of any length up to the length of the string itself. To sol...
1
0
['Array', 'String', 'Java']
0
count-prefixes-of-a-given-string
2 Line Solution || 100% faster || Single Pass
2-line-solution-100-faster-single-pass-b-v43p
Intuition\nIf given words are the substring at index 0, they are the desired string count\n Describe your first thoughts on how to solve this problem. \n\n# App
Nitesh_Gupta_NG
NORMAL
2024-06-07T18:25:42.451243+00:00
2024-06-07T18:25:42.451279+00:00
102
false
# Intuition\nIf given words are the substring at index 0, they are the desired string count\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\nUse indexOf function to validate, words are coming at first index or not\n<!-- Describe your approach to solving the problem. -->\n\n# Complexit...
1
0
['Java']
1
count-prefixes-of-a-given-string
[Java] Best solution in design scenario - Using Trie Tree
java-best-solution-in-design-scenario-us-kshz
java\nclass Solution {\n public int countPrefixes(final String[] words, final String s) {\n final TrieNode root = new TrieNode();\n\n // Insert
YTchouar
NORMAL
2024-05-08T06:59:02.029667+00:00
2024-05-08T06:59:13.506925+00:00
385
false
```java\nclass Solution {\n public int countPrefixes(final String[] words, final String s) {\n final TrieNode root = new TrieNode();\n\n // Insert all words in Trie\n\n for(final String word : words) {\n TrieNode curr = root;\n\n for(int i = 0; i < word.length(); ++i) {\n ...
1
0
['Java']
0
count-prefixes-of-a-given-string
Easiest C || C++ || Java Solutions -- 100% beats Easy[Simple]
easiest-c-c-java-solutions-100-beats-eas-qlco
Intuition\n\nC []\nint countPrefixes(char** words, int wordsSize, char* s) {\n int c = 0;\n for (int i = 0; i < wordsSize; i++) {\n strncmp(words[i
Edwards310
NORMAL
2024-02-03T06:39:31.690431+00:00
2024-02-03T06:39:31.690462+00:00
3
false
# Intuition\n![Screenshot 2024-02-03 120245.png](https://assets.leetcode.com/users/images/086330d7-c31f-49e7-9a64-568148447725_1706942027.7474754.png)\n```C []\nint countPrefixes(char** words, int wordsSize, char* s) {\n int c = 0;\n for (int i = 0; i < wordsSize; i++) {\n strncmp(words[i], s, strlen(words...
1
0
['C', 'C++', 'Java']
0
count-prefixes-of-a-given-string
Java || Simple Solution || 100% Beats
java-simple-solution-100-beats-by-akash_-3r88
\n# Code\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nclass Solution {\n public int countPrefixes(String[] words, String s) {\n int count
akash_kce
NORMAL
2024-02-01T09:51:01.589296+00:00
2024-02-01T09:51:01.589330+00:00
379
false
\n# Code\n```\nimport java.util.ArrayList;\nimport java.util.List;\n\nclass Solution {\n public int countPrefixes(String[] words, String s) {\n int count = 0;\n for (String i : words)\n if (s.startsWith(i)) count++;\n return count;\n }\n}\n\n```
1
0
['Array', 'String', 'Java']
0
count-prefixes-of-a-given-string
Easy one liner solution
easy-one-liner-solution-by-elangoram1998-95c9
\n# Code\n\nfunction countPrefixes(words: string[], s: string): number {\n return words.filter((word) => s.startsWith(word)).length;\n};\n
elangoram1998
NORMAL
2023-12-01T10:46:23.724286+00:00
2023-12-01T10:46:23.724312+00:00
45
false
\n# Code\n```\nfunction countPrefixes(words: string[], s: string): number {\n return words.filter((word) => s.startsWith(word)).length;\n};\n```
1
0
['TypeScript', 'JavaScript']
0
count-prefixes-of-a-given-string
Count Prefixes of a Given String Solution in C++
count-prefixes-of-a-given-string-solutio-humn
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-03-14T18:03:58.544456+00:00
2023-03-14T18:03:58.544490+00:00
51
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*m)\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n...
1
0
['C++']
0
count-prefixes-of-a-given-string
Ruby solution. 1-line
ruby-solution-1-line-by-guswhitten-rdez
\n# @param {String[]} words\n# @param {String} s\n# @return {Integer}\ndef count_prefixes(words, s)\n words.count { |word| s.start_with?(word) }\nend\n
guswhitten
NORMAL
2023-02-12T14:37:56.157570+00:00
2023-02-12T14:37:56.157600+00:00
7
false
```\n# @param {String[]} words\n# @param {String} s\n# @return {Integer}\ndef count_prefixes(words, s)\n words.count { |word| s.start_with?(word) }\nend\n```
1
0
['Ruby']
0