Reported July 2026
IBMhash table

String-Pair Frequency Similarity

Reported by candidates from IBM's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live IBM OA. Under 2s to a working solution.
Founder's read

IBM reported this one in July 2026, and it looks scarier than it is. Two arrays of strings, a similarity rule, a YES/NO answer per pair. Strip the wrapper and it's a 26-bucket letter count with a threshold check. That's a hash-table or counting-array problem, nothing more. If you've got an IBM OA coming up, expect the trap to be in the details, not the idea. If you blank on the day, StealthCoder sits invisibly on your screen and gives you the solution in real time. But you probably won't need it for this.

The problem

You are given two arrays of strings, s and t, each of length n. Each pair (s[i], t[i]) contains two lowercase English strings.
Two strings are considered similar when:
Every letter x from 'a' through 'z' is considered.
The absolute difference between the number of times x appears in the two strings is at most 3.
For each pair (s[i], t[i]), check whether the strings are similar. Return an array of n elements where each element is:
"YES" if the pair is similar.
"NO" otherwise.

Function
areSimilar(s: String[], t: String[]) → String[]

Examples
Example 1
s = ["aabaab","aaaaabb"]
t = ["bbabbc","abbbbbb"]
return = ["YES","NO"]
Analysis of s[0] and t[0]Letters[0] countt[0] countDifference
a413
b242
c011
Analysis of s[1] and t[1]Letters[1] countt[1] countDifference
a514
b264
The numbers of occurrences of a, b, and c in s[0] and t[0] never differ by more than 3, so this pair is similar. In s[1] and t[1], both a and b violate the condition, so this pair is not similar.

Constraints
1 <= s.length = t.length <= 5.
Each string contains only lowercase English letters.
Every string has length from 1 through 100000, inclusive.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick: for each pair, count letters in both strings using a size-26 array, then loop a through z and check whether abs(cs[x] - ct[x]) is at most 3. If any letter breaks that, answer NO. Otherwise YES. That's O(L) per pair with constant extra space, and there are at most 5 pairs, so the total work is tiny. The common pitfalls are sloppy. People forget letters that appear in only one string, so the count in the other is zero and the difference still matters. Others compare only the letters in the first string. Always iterate all 26 letters. Strings go up to 100000 characters, so don't sort or do anything quadratic. Use one pass per string. Return an array of strings, exactly "YES" or "NO" in caps. If you freeze during the live IBM assessment, StealthCoder is the hedge that hands you the working code.

The honest play: practice the pattern, and have StealthCoder ready for the one you didn't see coming.

If this hits your live OA

You can drill String-Pair Frequency Similarity cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play.

Get StealthCoder

Related leaked OAs

⏵ The honest play

You've seen the question. Make sure you actually pass IBM's OA.

IBM reuses patterns across OAs. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play. Works on HackerRank, CodeSignal, CoderPad, and Karat.

String-Pair Frequency Similarity FAQ

How hard is the String-Pair Frequency Similarity problem really?+

Easy. It's a frequency count with a threshold check. The logic is a few lines once you see it. The only way to lose points is skipping letters that appear in just one string or mishandling the output format.

What's the trick to solving it fast?+

Use two int arrays of size 26. Increment for each character in s[i] and t[i]. Then loop all 26 letters and check the absolute difference is at most 3. One failure means NO. No sorting, no maps needed.

What's the time and space complexity?+

Time is O(L) per pair where L is the string length, up to 100000, with at most 5 pairs. Space is O(1) since the count arrays are fixed at 26. A hash map works too but a plain array is cleaner and faster.

What edge cases should I test before submitting?+

Test a letter present in only one string, since the difference equals its full count. Test a difference of exactly 3, which is YES, and exactly 4, which is NO. Test single-character strings and maximum-length strings for speed.

How do I prepare for this in 48 hours?+

Write the 26-bucket counting pattern from memory a few times. Practice reading a problem and spotting that the wrapper hides a simple count. Check your output strings match case exactly. That covers this problem and many like it.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with IBM.

OA at IBM?
Invisible during screen share
Get it