Adobe Interview Question

1. Find a string in an unsorted array of strings. 2. Search for a string in a sorted array of strings. Your solution can be coded in any language you choose.

Interview Answers

Anonymous

Feb 5, 2017

1. Simply traversed through the array till I found it, O(N). 2. Implemented binary search in Python, O(log N). Both of my solutions were written in Python.

1

Anonymous

Feb 18, 2017

I'm not sure this is correct. Assume == has a time complexity of f(m). For #1 you are traversing the entire array, which is definitely O(N), but each time, you are doing f(m) work. This suggests the asymptotic runtime would be O(N*f(m)), and in the case of comparing strings, it takes the length of the smaller string to tell if it's equal or not. So, it would be O(N*Min(M,L)) where M is the length of the string in each bucket and L is the length of the query string. Similar logic applies for the second, which I'm assuming you applied a binary search on.

1