You are given an array of unique strings features and an array of strings responses. Each element in responses is a string consisting of space separated words.
The popularity of a feature is defined as the total number of responses in responses that contain the feature as an individual word at least once.
Sort the features array in descending order based on each feature’s popularity. If multiple features have the same popularity, maintain their original relative order from features.
Return the sorted features array.
Constraints:
features.length
features[i].length
features contains no duplicates.
features[i] consists of lowercase English letters.
responses.length
responses[i].length
responses[i] consists of lowercase English letters and spaces.
responses[i] contains no two consecutive spaces.
responses[i] has no leading or trailing spaces.
You are given an array of unique strings features and an array of strings responses. Each element in responses is a string consisting of space separated words.
The popularity of a feature is defined as the total number of responses in responses that contain the feature as an individual word at least once.
Sort the features array in descending order based on each feature’s popularity. If multiple features have the same popularity, maintain their original relative order from features.
Return the sorted features array.
Constraints:
features.length
features[i].length
features contains no duplicates.
features[i] consists of lowercase English letters.
responses.length
responses[i].length
responses[i] consists of lowercase English letters and spaces.
responses[i] contains no two consecutive spaces.
responses[i] has no leading or trailing spaces.