2 Line Solution || 100% faster || Single Pass
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
# 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# 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 countPrefixes(String[] words, String s) {\n        int count = 0;\n        for(String w:words) if(s.indexOf(w)==0) count++;\n        return count;\n    }\n}\n```
['Java']