You are viewing a single comment's thread. Return to all comments →
You could use ascii code and not define a another string.
Also, you could iterate through each char in s1 and compare with each char in s2.
Still, this is a bad approach, because the runtime complexity is O(n* m).
Using hashtables can make a linear time of O(n+m), which is much faster.
This excercise is all about dictionaries and hashtables, so I suggest using them, otherwise you could fail an interview test by not practicing them.
Seems like cookies are disabled on this browser, please enable them to open this website
Two Strings
You are viewing a single comment's thread. Return to all comments →
You could use ascii code and not define a another string.
Also, you could iterate through each char in s1 and compare with each char in s2.
Still, this is a bad approach, because the runtime complexity is O(n* m).
Using hashtables can make a linear time of O(n+m), which is much faster.
This excercise is all about dictionaries and hashtables, so I suggest using them, otherwise you could fail an interview test by not practicing them.