Пожалуйста, прочтите новое правило об ограничении использования AI-инструментов. ×

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

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

In this question, DIV 2C, Is is possible to solve this using recursive approach without exceeding the memory limit??

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

»
8 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Auto comment: topic has been updated by skpro19 (previous revision, new revision, compare).

»
8 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

You don't need to convert it. You can use simple memory optimisation in this question because the current state i depends only on the previous state i-1.

So you can use i%2 instead of i and that would save a lot of memory.

Have a look in this code here: Code

  • »
    »
    8 лет назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    The thing is, I always solve dp problems recursively, so i was wondering will it be possible to solve it in a recursive fashion without exceeding the memory limit? I do understand the bottom up approach though.