Easiest C || C++ || Java Solutions -- 100% beats Easy[Simple]
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
# 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[i])) == 0 && c++;\n    }\n    return c;\n}\n```\n``` Java []\nclass Solution {\n    public int countPrefixes(String[] words, String s) {\n        int cnt = 0;\n        for (int i = 0; i < words.length; i++) {\n            if (s.startsWith(words[i]))\n                cnt++;\n        }\n        return cnt;\n    }\n}\n```\n```C++ []\nclass Solution {\npublic:\n    int countPrefixes(vector<string>& words, string s) {\n        int cnt = 0;\n        for (auto& it : words) {\n            string str = s.substr(0, it.size());\n            if (str == it)\n                cnt++;\n        }\n\n        return cnt;\n    }\n};\n```\n```C []\nint countPrefixes(char** words, int wordsSize, char* s) {\n    int count = 0;\n    bool add;\n    for (int i = 0; i < wordsSize; i++) {\n\n        add = true;\n        char* x = words[i];\n        for (int j = 0; x[j]; j++)\n            if (!s[j] || s[j] != x[j]) {\n                add = false;\n                break;\n            }\n\n        if (add)\n            count++;\n    }\n    return count;\n}\n```\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     O(n)\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n     O(1)\n# Code\n```\nclass Solution {\n    public int countPrefixes(String[] words, String s) {\n        int cnt = 0;\n        for (int i = 0; i < words.length; i++) {\n            if (s.startsWith(words[i]))\n                cnt++;\n        }\n        return cnt;\n    }\n}\n```
['C', 'C++', 'Java']