GeeksforGeeks » Interview Questions

Choose numbers from sets such that their sum is equal to P

(1 post)
  • Started 6 months ago by cvusminpwb

Tags:

  1. jack
    guest
    Posted 6 months ago #

    There are K sets. Each set can contain n numbers from 0 to n. we've to choose exactly one number from each set auch that the sum of all the elements that we chose should be equal to P. we have to find how many such possibilities are there to choose so..

    for example
    assume there are 3 sets containing 1,2,3 elements in them
    so the first set contains 0 and 1
    second set contains 0,1 and 2
    third set contains 0,1,2 and 3

    assume P=2

    in this case there are 5 possibilities

    (0,0,2), (0,1,1), (0,2,0), (1,0,1), (1,1,0)


Reply

You must log in to post.

RSS feed for this topic