Round 1
Questions:
Question 1
Given two arrays one is sub array of another and order of words also same, print the common word in both arrays following the same order.
Ex: arr1 = [I, love, leetcode, programming], arr2 = [I, love, programming]
output : [I, love, programming]
Ex: arr1 = [I, love, programming, and, DSA], arr2 = [I, love, DSA, and, programming]
output : [I, love, programming]
we need to follow order based on arr1
Question 2
Given a str and min length, max length, max freq of char, return the max count of substring with length greater than or equal to min length and less than or equal to max length and no characters appear more than max freq of char times:
if two strings have same freq return lexicographically small.
Ex: s = 'abcabc', minlength = 2, maxlength = 6, max freq = 1
sub strings = [ab, abc, bc, bca, ca, cab, ab, abc]
in this case: abca, bcab, cabc, abcab, bcabc, abcabc are not valid because there are characters repeating more than max freq times:
output: ab (freq: 2)
Candidate's Approach
For Question 1, I used a brute force approach to compare both arrays and collect the common words while maintaining the order from the first array.
For Question 2, I generated all possible substrings within the specified length limits and filtered them based on the frequency of characters. I ensured that no character appeared more than the allowed maximum frequency. Finally, I selected the valid substrings and returned the lexicographically smallest one if there were ties in frequency.
Interviewer's Feedback
No feedback provided.