C job interview - casting and comparing

后端 未结 10 728
没有蜡笔的小新
没有蜡笔的小新 2021-02-01 12:29

I was confronted with a tricky (IMO) question. I needed to compare two MAC addresses, in the most efficient manner.

The only thought that crossed my mind in that moment

10条回答
  •  情话喂你
    2021-02-01 12:48

    If your interviewer demands that you produce undefined behavior, I would probably look for a job elsewhere.

    The correct initial approach would be to store the MAC address in something like a uint64_t, at least in-memory. Then comparisons would be trivial, and implementable efficiently.

提交回复
热议问题