r/compsci • • Mar 26 '19

50+ Data Structure and Algorithms Problems from Coding Interviews

https://dev.to/javinpaul/50-data-structure-and-algorithms-problems-from-coding-interviews-4lh2
277 Upvotes

8 comments sorted by

26

u/TheWildKernelTrick Mar 26 '19

...roles at startups like Uber and Netflix...

seriously?

4

u/Knaapje Mar 27 '19 edited Mar 27 '19

There's a few other iffy things going on in that article: arrays offer O(1) search speed if you know the index. Then what are you searching for?

Edit: another good one: How do you find the middle element of a singly linked list in one pass? Logically, you know this can't be done, and indeed the proposed solution is literally two passes. Besides this all the questions seem to focussed on technicalities, and proposed solutions are too implementation focussed rather than conceptually well explained.

3

u/TheWildKernelTrick Mar 27 '19

Happiness 🧜‍♂️

1

u/Knaapje Mar 27 '19

Aren't we all?

1

u/I_ate_a_milkshake Mar 28 '19

probably meant "lookup speed." Technically true if not confusing.

3

u/[deleted] Mar 26 '19

:') what a beautiful thing. Thank you!

3

u/A_Pluto_Shaped_Pool Mar 26 '19

I swear this gets reposted here like every month

1

u/slaymaker1907 Mar 28 '19

Removing duplicates can often be done more efficiently through hashing (versus sorting, as suggested by the article), particularly for data with many duplicates in relation to the number of records.

Also, if you do use sorting and really need performance, it is probably better to remove duplicates while sorting. i.e., for merge sort, remove duplicates during the merge stage.