Count Element Occurence


#1
#include<iostream>
#include<algorithm>
using namespace std;
#include<vector>
#include<map>
int main () {
   vector<int>A={5, 7, 7, 8, 8,8, 10};
    int B=8;
    map<int,int>m;
    for(int i=0; i<A.size();i++)
        m[A[i]]+=1;
    cout<<m[7];

}

#4

is it fair to write this kind of short code using STL in c++(in case of coding placement test)??


#5

Your solution is O(n), but O(logn) is required.