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

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

suppose i have an array of n=5 elements say A={50,10,20,30,40}; when I pick i element from the array I can not pick i+1 element from the array. So how much value can I pick which will not exceed 100. So in this case I can pick maximum {50,40} which is less than 100. I tried to solve this using recursion, but i failed to do so because i can't establish any relation. How can I do so? Please help... I am new to recursion related topic.. TIA...

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

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

It's my solution of your problem. I think you will understand it. Write if you have any questions. http://pastebin.com/fYtRBUpv