by black3r · 6y ago · 0 comments
If I were interviewing someone, I would expect the linear solution and from a CS graduate would at least expect mentioning the logarithmic one..
defmodule Fibnoc do
def fib(0), do: []
def fib(1), do: [0]
def fib(2), do: [1 | fib(1)]
def fib(n) when n > 2 and is_number(n) do
[a, b | _] = rest = fib(n - 1)
IO.puts("a: #{a} b: #{b} rest: #{inspect(rest)}")
[a + b | rest]
end
end
Although I wouldn't call these questions a great way to assess people for the job, they are fine as a way to weed out people who can't program at all. Most high schoolers spend hours leetcoding these days. I do wonder how tough the market would be by the time I can legally work given current trends of everyone jumping into IT jobs.That's what I mean tho. In high school, they start leetcode practice from day 1 of programming or CS classes. Soon, you will get many leetcoders in the market.
> How does implementing Fibonacci weed out people who can't program at all?
There are many people applying for jobs who can't program a buzz fizz. They exist. A fibonacci is enough to throw them off in an unfamiliar language.
Also why stop there? An actual smart coder would have looked up the constant time solution instead of bothering with any of that.