PARALLEL On-Campus OA (2024) | Count Prefixes of a Given String

Question · Posted Jun 2026

Problem Statement You are given an array of strings words and a string s. Return the number of strings in words that are prefixes of s. A string is a prefix of another string if it matches the beginning characters of that string. Example Input words = ["a","b","c","ab","bc","abc"] s = "abc" Output 3 Explanation The prefixes of "abc" present in the array are: "a" "ab" "abc" Total = 3 Constraints 1 <= words.length <= 1000 1 <= words[i].length <= 20 ...

The full answer & interview discussion are available to premium members.

Log in Create a free account