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

Автор Honestly, история, 10 месяцев назад, По-английски

While solving dp ,i think we have all solved the problem subset sum==target ,its pretty basic ,now what if there were q queries for different target sums,obviously the brute force wud be to reconfigure the dp array before each query ,but the whole process would then take O(N*Q*T) time ,which has a high chance of giving TLE, can you guys suggest ways to initialize the dp array only once ,and keep it constant across all queries ?

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

»
10 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

store the values of target left instead of sum we made.

»
10 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

use bitset :)