DARWINBOX Off-Campus Hiring | Check Whether Two Strings are Almost Equivalent | 2024
darwinbox · Question · Posted Jun 2026
Problem Statement Two strings word1 and word2 are called almost equivalent if the difference in frequency of every lowercase English letter is at most 3. Return: true if the strings are almost equivalent. false otherwise. Example 1 Input word1 = "aaaa" word2 = "bccb" Output false Explanation Frequency of 'a': word1 = 4 word2 = 0 Difference = 4 > 3 Hence the strings are not almost equivalent. Example 2 Input word1 = "abcdeef" word2 = "abaaacc" Output true
The full answer & interview discussion are available to premium members.
Log in Create a free account