I am solving this question as an assignment of the school. But the two of my test cases are coming out wrong when I submit the code? I don't know what went wrong. I have checked various other test cases and corner cases and it all coming out right. 

**Here is my code:**

```
    public static boolean isPermutation(String input1, String input2) {

       if(input1.length() != input2.length())
       {
           return false;
       }

       int index1 =0;
       int index2 =0;
       int count=0;

       while(index2<input2.length())
       {

           while(index1<input1.length())
           {
               if( input1.charAt(index1)==input2.charAt(index2) )
               {
                   index1=0;
                   count++;
                   break;
               }
             index1++;     

           }
           index2++;
       }

       if(count==input1.length())
       {
           return true;
       }

       return false;

}

```

**SAMPLE INPUT**

```
abcde
baedc

```

**output**

```
true

```

**SAMPLE INPUT**

```
abc
cbd

```

**output**

```
false

```