Count Suffix-Related Word Pairs
Updated
Problem statement
You are given an array of strings words. Count unordered index pairs (i, j) with i < j for which either word is a suffix of the other.
Equal words qualify.
Function
countSuffixPairs(words: String[]) → longExamples
Example 1
words = ["a","ba","cba","x"]return = 3a is a suffix of ba and cba, and ba is a suffix of cba.
Example 2
words = ["x","x","yx"]return = 3The equal x values qualify, and each is a suffix of yx.
Constraints
0 <= words.length <= 20000 <= words[i].length <= 1000- Words contain lowercase English letters.
More ZipRecruiter Online Assessment questions
- Four-Level Banking System with Scheduled PaymentsOA · Seen Oct 2026
- Count Three-Digit Numbers with Distinct DigitsOA · Seen Oct 2024
- Longest Frequency-Bounded SubarrayOA · Seen Oct 2024
- Minimum Changes to Draw a YOA · Seen Oct 2024
- Apply Binary State OperationsOA · Seen Sep 2024
- Simulate Orchard Rot SpreadOA · Seen Sep 2024
- Compare Odd- and Even-Index SumsOA · Seen Sep 2024
- Coordinate Removals with Column GravityOA · Seen Sep 2024
- Lexicographically Smallest End ReversalOA · Seen Sep 2024
- Recursively Expanded Shell Command CountsOA · Seen Sep 2024
Similar questions at other companies
- Count User Mentions in Chat MessagesRamp · OA
- Find Words That Can Be Formed by CharactersTabaPay · OA
- Word Frequency Counts in Alphabetical OrderAbridge · OA
- Count Multiples of Three with Two SevensHudson River Trading · OA
- Customer Signer ScreeningState Farm · OA
- REST API: Highest International StudentsRippling · OA
- String-Pair Frequency SimilarityIBM · OA
- Find Sliding-Window Pattern Start IndicesVisa · OA
- Closest ColorTwo Sigma · OA
- Number-Character Bijective MappingAdobe · OA