leetle

Daily challenge for 2026-06-20

536. Distinct Prefix Suffix Pairs

Given a list of strings words, find the number of distinct strings in the list that appear at least once as a prefix of a *different* string in the list, and at least once as a suffix of a *different* string in the list.

Example:
Input: words = ["a", "ab", "ba"]
Output: 1
Explanation: "a" is a prefix of "ab" and a suffix of "ba".

Run this challenge interactively in Python or JavaScript when the app loads.