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

Автор naivedyam, история, 4 часа назад, По-английски

I have just started recursion and while most of the concepts were pretty easy for me to understand and apply, I am stuck with one particular one — the famous Subset problem of Leetcode where you have to return all possible subsets of a set. I have seen the solution, watched an explanation but still feel I don't truly understand it. Never been so much stuck with a problem before. Also, I don't think it is a problem that can be skipped because since the time I first saw it (last week) I have reduced 5 different problems to it including one in a contest (which I obviously couldn't implement even after figuring out the logic because I can't solve the subset problem). I have also reduced some CSES problems like Apple Divison to it, but again, unable to solve for the same reason. Could anyone suggest any resources for the same?

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

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

A bit advanced of an idea for a pupil-ranked, but have you considered using bitmasks to distinguish between subsets?

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

    Nope I have just started the basics of bit manipulation right now. Trying to get it done the recursive way (since the place I am learning it from asks us to solve using recursion)

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

Just dry run the solution . It helps alot. I faced this issue too but after solving multiple questions of recursion I became comfortable. Make sure you dry run until you get good