All Posts

Leetcode 2185: Counting Words With a Given Prefix

You are given an array of strings and a target prefix. Your task is to count how many strings in the array start with this target prefix.

Leetcode 3042: Count Prefix and Suffix Pairs I

You are given a 0-indexed string array words. You need to determine the number of index pairs (i, j) such that i < j and the string at index i is both a prefix and a suffix of the string at index j. The function isPrefixAndSuffix(str1, str2) returns true if str1 is both a prefix and a suffix of str2, and false otherwise.