Code works fine with sample test case but fails when I submit the code

When I submit the code it give me error.Here is link for my code


Please let me where I am wrong

this is the logic read once and try again where are you going wrong…

1.First sort the given array.
2.Now take two variables one as left and other as right starting from 0th and end index of the sorted array respectively.
3.Now iterate till left<right.
3.1 Calculate the sum of the elements at left and right position
3.1.1 If the sum is equal to the target then print both the elements. //printing target sum pairs
3.1.2 If the sum is less than the target then increase the left by 1
3.1.3 Else decrease the right by 1
4.End loop.Thus, all the pairs has been printed .

public static void roses(int[] arr, int target) {

     Arrays.sort(arr); // sort the Array

     int fl = 0;  //To store the leftmost index
     int fr = 0;    //To store the rightmost index

     int left = 0;
     int right = arr.length - 1;

     while (left < right) {

          int sum = arr[left] + arr[right];

          if (sum > target) {
               right--;
          } else if (sum < target) {
               left++;
          } else {
               fl = left;
               fr = right;

               left++;
               right--;
          }

     }

     System.out.println("Deepak should buy roses whose prices are " + fl + " and " + fr + ".");

}

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.