Search
 
SCRIPT & CODE EXAMPLE
 

CPP

Count Prefix of a Given String solution leetcode

class Solution {
public:
    int countPrefixes(vector<string>& words, string s) {
        map<string,int> mp;
        int n = s.size();
        string temp;
        for(int i=0;i<n;i++){
            temp += s[i];
            mp[temp]++;
        }
        int n1 = words.size();
        int count = 0;
        for(int i=0;i<n1;i++){
            if(mp.find(words[i])!=mp.end())
                count++;
        }
        return count;
    }
};
Comment

PREVIOUS NEXT
Code Example
Cpp :: c++ fstream 
Cpp :: indexing strings in c++ 
Cpp :: cpp vector2 
Cpp :: find index of element in array c++ 
Cpp :: check if set contains element c++ 
Cpp :: insert only unique values into vector 
Cpp :: stringstream stream number to string 
Cpp :: how to sort in descending order in c++ 
Cpp :: even and odd sum in c++ 
Cpp :: palindrome program in c++ 
Cpp :: c++ rand include 
Cpp :: push local branch to another remote branch 
Cpp :: sizeof’ on array function parameter ‘arr’ will return size of ‘int*’ [-Wsizeof-array-argument] 
Cpp :: inline in class in C++ 
Cpp :: unique_ptr syntax 
Cpp :: cpp mutex 
Cpp :: C++ Limit of Integer 
Cpp :: remove first occurrence of value from vector c++ 
Cpp :: how to initialize vector 
Cpp :: c++ operator overloading 
Cpp :: login system with c++ 
Cpp :: c++ saying hello world 
Cpp :: c++ #include 
Cpp :: array of struct in c++ 
Cpp :: system("pause") note working c++ 
Cpp :: string number to integer number C++ 
Cpp :: c++ inheritance constructor 
Cpp :: c++ Attribute Parser 
Cpp :: oncomponentendoverlap ue4 c++ 
Cpp :: why use python 
ADD CONTENT
Topic
Content
Source link
Name
2+3 =