Math Related Problem
Pure math related problems are rarely asked during an interview. That is because an interview is usually testing an interviewee’s problem solving skills. Most math problems are based on some theorems, and those theorems are hard to infer in a short time. Therefore, it is hard to show problem solving skills by resolving a pure math problem. In this article, we will focus on introducing some common used theorems to inspire sparks.
Original thought are inspired by labuladong
Bit Operation:
Most often used bit operations are or
, and
, xor
. There are many tricky and interesting skills. Here we will only focus on two of them.
n &(n - 1)
: This operation can remove the last bit of1
inn
.xor
operation :a ^ a = 0
a ^ 0 = a
The prove will not be shown here, but you can use examples to infer theorems.
Factorial Calculation:
Factorial problems usually are not resolved by actual factorial calculation because factorial calculation’s time complexity is very big. We often need to find patterns to get result without a complete factorial computation .