4 ms·
well, n is supposed to be a 32 bits integer int. Not a lambda. if f(n) returns a lambda, it can't be composed with f again, according to the strict definition o
by bsaul 13y ago
well, n is supposed to be a 32 bits integer int. Not a lambda. if f(n) returns a lambda, it can't be composed with f again, according to the strict definition of "n".
- viraptor 13y agoAnd it is. The question is: f(f(n)) == -n Where n is a 32 bit signed integer It's `f(n)` that is not a signed integer. Both `n` and `f(f(n))` are ints, so the answer is within the constraints. There's nothing said about the signature of the function.
- bsaul 13y agothat seems a bit far fetched. the way i understand n, it means " f input ", as "the parameter that f takes as input, whose type is an integer". Anyway, that's probably just one way of reading the question. Really depends on what the interviewer's intention was.
- petercooper 13y agoTherein lies a lesson for the interviewer, "your spec is too vague" :-)