Math Related Problems

Key Points

  • Edged Case

    • Case of overflow
  • Performance

    • Utilize bit operation for Power calculation.

Problems

Problems - Mod & Power Problems

Key Points

  • About Mod. A*B % k = (A % k) * (B % k) % K
  • Quick Power, for Power(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)

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 -

References

  1. Mod Problems

results matching ""

    No results matching ""