public int[] solve (int[] a) {         List<Integer> list = new ArrayList<>();         for(int i=0;i<a.length;i++){             list.add(a[i]);         }         List<Integer> list1 = new ArrayList<>();         Arrays.sort(a);         boolean[] paduan = new boolean[a.length];         int j = a.length-1;         Stack<Integer> stack = new Stack<>();         for(int i=0;i<a.length;i++){             int temp = list.get(i);             if(temp!=a[j]){                 stack.push(temp);                 paduan[i]=true;             }             if(temp==a[j]){                 if(paduan[i]==true){                     list1.add(stack.pop());                 }else{                     paduan[i]=true;                     list1.add(temp);                 }                 j--;             }         }         while(!stack.isEmpty()){             list1.add(stack.pop());         }         for(int i=0;i<list1.size();i++){             a[i] = list1.get(i);         }         return a;     }