DEV Community

loading...

Discussion on: I failed an interview because of an algorithm

Collapse
theodesp profile image
Theofanis Despoudis

The way I see it is using a custom comparator function in Array.prototype.sort taking care of the details. For example: split by dots . and compare each positional number with each other.

Collapse
luiz0x29a profile image
Real AI

That's the solution anyone would expect, you don't need to know any algorithm for sort, but passing a comparator is such a basic thing.
You don't even need any algorithm to solve the problem.

Collapse
dannyengelman profile image
Danny Engelman

Typical example where humans fail. When they see numbers they want to calculate with numbers. Almost all 30+ answers in the mentioned SO thread do so.
I just added my answer. And probably would have failed every job interview if they only excepted the solution they themselves came up with.

stackoverflow.com/questions/683259...