Code Not Working

I Have copy the same code in my software but not working properly output is different

Please see the code and output and tell me what the problem

Hey @nishant7822badaya In the photo you send I am not able to see mergeSort function. Please sen me your full code.

import java.util.*; public class Main { public static void main(String args[]) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int[] arr=new int[n]; for(int i=0;i<n;i++){ arr[i]=sc.nextInt(); } int[] finalMergeSortArray=mergeSort(arr,0,arr.length-1); for(int a:finalMergeSortArray){ System.out.print(a+" "); } } public static int[] mergeSort(int[] arr,int l,int h){ if(l==h){ int[] br=new int[1]; br[0]=arr[l]; return br; } int mid=(l+h)/2; int[] fh=mergeSort(arr,l,mid); int[] sh=mergeSort(arr,mid+1,h); return mergeSortedArray(fh,sh); } private static int[] mergeSortedArray(int[] fh, int[] sh) { int i=0,j=0,k=0; int[] mergedArray=new int[fh.length+sh.length]; while(i<fh.length && j<sh.length){ if(fh[i]<sh[j]){ mergedArray[k]=fh[i]; i++; } else{ mergedArray[k]=sh[j]; j++; } k++; } if(i==fh.length){ while(j<sh.length){ mergedArray[k]=sh[j]; j++; k++; } } return mergedArray; } }

Hey @nishant7822badaya The code you just sent is not possible to read.
So instead add your code in the below link and click save(click file then click save).

save file at given path please check

Hey @nishant7822badaya Sorry for the inconvience but you haven’t saved the file. So try to take screenshot of whole code and then send it to me.

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.