Why it is not finding 'sort' library method ?

  • 0
    public class Solution {
        int[] arr;
        public String largestNumber(int[] nums) {
            int max=Integer.MIN_VALUE;
            for(int i=0; i<nums.length; i++)
                max = Math.max(max, nums[i]);
            int len = Integer.toString(max).length();
            int[] arr = nums;
            int div = (int)Math.pow(10, len);
            for(int i=0; i<nums.length; i++) {
                while((arr[i]*10)/div <=0)
                    arr[i] *= 10;
            Arrays.sort(nums, new MyComparator());
            //return nums converting to string
            return  null;
        private class MyComparator implements Comparator<Integer> {
            public int compare(Integer i1, Integer i2) {
                return arr[i1.intValue()].compareTo(arr[i2.intValue()]);

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.