Math Related Problems
Key Points
Edged Case
- Case of
overflow
- Case of
Performance
- Utilize
bit operationforPowercalculation.
- Utilize
Problems
Problems - Mod & Power Problems
Key Points
- About
Mod.A*B % k = (A % k) * (B % k) % K - Quick
Power, forPower(x, n). O(N) => O(lgN)- if
n % 2 == 1, =>x * Power(x, n-1) - if
n % 2 == 0, =>Power(Power(x, n/2), 2)
- if
Problems
| Problems | Possible Solutions | Key Points | Code | Comments |
|---|---|---|---|---|
| 50. Pow(x, n) | 1. If n == math.MinInt32 2. If n is very large, how to reduce the time complexity? |
code | - | |
| 372. Super Pow | 1. Iteration or Recursion for the array.2. Utilize bit operation for Power calculation |
code | - |