I have a problem:-
There are m men and m women. Male may dance with one or more women or may not dance with any. Find One to one dancing partner pairs such that:
1. male dance partner is paired with women of his choice
2. No male or female dancer is left alone

```
public class DancePair 
{ 

    public static int totalmatching(int input1,String[] input2)
    {
        //Write code here
        String[] words=new String[input1];
        String[] words2=new String[input1];
        int i,j;
        System.out.println(input1);

        for(i=0;i<input1;i++)
        {
            words=input2[i].split("\\#");
            for(j=1;j<words.length;j++)
            {
                for(k=i+1;k<input1;k++)
                {
                    words2=input2[k].split("\\#");
                    for(p=1;p<words2.length;p++)
                    {
                        if(words[j]==words2.[p])
                        {
                            p++;
                            continue;
                        }
                        else
                        {
                            words3=input2[k+1].split("\\#");

                        }
                    }
                }

            }

        }
        return 0;
    }
}

```

Input is like:- M1#W2#W4,M2#W1#W2,M3#W1#W3#W4,M4#W4#W5,M5#W4
OUTPUT should come for this i/p as 1
I have created this code but i am stucking in the loop and unable to proceed. Need help