Блог пользователя antivenom

Автор antivenom, история, 11 лет назад, По-английски

Hello everyone,I am new to Dynamic programming and what I have observed that in any question whenever I think that this is a permutation combination question,it comes out to be a DP.So my question from you guys is that is permutation and combination Dp in competitive coding.Like this question I thought of P&C but its a Dp

  • Проголосовать: нравится
  • +5
  • Проголосовать: не нравится

»
11 лет назад, скрыть # |
 
Проголосовать: нравится +5 Проголосовать: не нравится

Combinations and DP are closely related: C(n, k) = C(n - 1, k - 1) + C(n - 1, k).

Usually you only need to think about combinations when you have to optimize from O(n2) to O(n). Then you can use the factorial formula to find C(n, k) in constant time with O(n) precomputation.