You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Gary is a teacher at XYZ school. To reward his N students he bought a packet of N candies all with different flavours. But the problem is some students like certain flavour while some doesn't. Now Gary wants to know the number of ways he can distribute these N candies to his N students such that every student gets exactly one candy he likes.
11
+
Input Format :
12
+
Line 1 : An integer N (1<= N <= 16) denoting number of students and candies.
13
+
Next N lines : N integers describing the preferences of one student. 1 at i'th (0 <= i < N) position denotes that this student likes i'th candy , 0 means he doesn't.
14
+
Assume input to be 0-indexed based.
15
+
Output Format :
16
+
Return the number of ways Gary can distribute these N candies to his N students such that every student gets exactly one candy he likes.``
0 commit comments