Designing function f(f(n)) == -n

前端 未结 30 2809
清酒与你
清酒与你 2020-12-02 03:32

A question I got on my last interview:

Design a function f, such that:

f(f(n)) == -n

Where n<

30条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-02 03:43

    I could imagine using the 31st bit as an imaginary (i) bit would be an approach that would support half the total range.

提交回复
热议问题