We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Don't be discouraged! that is the idea behind this--interviewers will want to see that you can see "what the question is really asking" and then implement a solution that is optimal from a big-O perspective.
In this case, mapping the characters in the strings into a bitmap and then ANDing the bitmap operates in O(s1.length + s2.length) time. for perspective, linearly walking through each character and checking indexes operates in O(s1.length * s2.length) time (times not plus).
Two Strings
You are viewing a single comment's thread. Return to all comments →
Don't be discouraged! that is the idea behind this--interviewers will want to see that you can see "what the question is really asking" and then implement a solution that is optimal from a big-O perspective. In this case, mapping the characters in the strings into a bitmap and then ANDing the bitmap operates in O(s1.length + s2.length) time. for perspective, linearly walking through each character and checking indexes operates in O(s1.length * s2.length) time (times not plus).