46. implement Subtract<A, B>

TypeScript

  - accepted / - tried

Similar to 38. implement Add<A, B>, please implement Subtract<A, B>.

  1. only need to consider positive integers
  2. B is guaranteed to be smaller or equal to A
type A = Subtract<1, 1> // 0
type B = Subtract<10, 3> // 7
type C = Subtract<3, 10> // never

Let's try to solve this problem within 10 minutes.

Discuss(3)