Company: Ion Group - Hackerrank

Difficulty: easy

Problem Statement

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 if, for every letter x from 'a' to 'z' , the absolute difference between the number of times x appears in the two strings is at most 3 . Your task: for each pair (s[i], t[i]) , decide whether the two strings are similar, and report YES if they are and NO otherwise. Example Suppose s = ["aabaab", "aaaaabb"] and t = ["bbabbc", "abbbbbb"] . The answer is ["YES", "NO"] . Analysis of the first pair: letter s[0] count t[0] count difference a 4 1 3 b 2 4 2 c 0 1 1 No letter differs by more than 3, so this pair is similar. Analysis of the second pair: letter s[1] count t[1] count difference a 5 1 4 b 2 6 4 Here 'a' and 'b' both violate the condition, so this pair is not similar. Input Format The first line contains an integer n . The next n lines each contain one string element of s . The next line contains the integer n again. The

More Ion Group - Hackerrank OA questionsInterview experiences