Question: solve this problem in java 8 EN - GB There are N patients ( numbered from 0 to N - 1 ) who want to

solve this problem in java 8
EN-GB
There are N patients (numbered from 0to N-1)who want to visit the doctor has S possible appointment slots, numbered from 1to S.
Each of the patients has two preferences. Patient K would like to visit the doctor during either slot A[K}or slot B[K].
The doctor can treat only one patient during each slot.
write a function:
class Solution { public boolean solution(int[] A, int[] B, int S); }
that, given two arrays A and B,both of N integers and an integer S,returns True of it is possible to assign every patient to one of their preferred slots,
one patient to one slot and False otherwise
Example:
1)Given A=[1,1,3],B=[2,2,1]and S =3,the function should return true
2)Given A =[3,2,3,1],B=[1,3,1,2]and S =3,the function should return False
3)Given A =[2,5,6,5],B=[5,4,2,2]and S =8,the function should return True

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!