Allocating leads to any number of users?

Allocating leads to any number of users?

Say I have two users (A and B) who sometimes work together and sometimes independently.

Specifically:
  • if A and B worked together on lead 1
  • if A worked alone toward lead 2
  • if lead 3 belongs to B alone
Then leads 1 should be shared between A and B, while lead 2 should be exclusively visible to A, and similarly, only B should see lead 3.

Is there a way to correctly assign leads in the above cases, using roles, groups or a combination? Or, is it a case of too many pegs and not enough holes? Ideally, your solution should scale to N number of users, and 2^N - 1 sub-groups.

Thanks in advance