C language - cannot be solved


  • 0

    Hi,
    Currently It's not possible to use C language to solve this task.
    I have error:
    "Variable column size in 2d array is not supported. Column size expected to be constant size (3) but got size (2)."
    Admins, Please fix.


  • 0

    This is just fixed. Please reload the default code definition and try again.


  • 0

    @1337c0d3r
    Could you please take a look why my code in JAVA doesn't work either, I saw couple identical solution in discussions, and have no clue why it fails with the message
    Line 8: error: incompatible types: List<List<Integer>> cannot be converted to int[][]

    public class Solution {
        public int maxDistance(int[][] arrays) {
            int result = Integer.MIN_VALUE;
            int max = arrays[0][arrays[0].length - 1];
            int min = arrays[0][0];
            
            for (int i = 1; i < arrays.length; i++) {
                result = Math.max(result, Math.abs(arrays[i][0] - max));
                result = Math.max(result, Math.abs(arrays[i][arrays[i].length - 1] - min));
                max = Math.max(max, arrays[i][arrays[i].length - 1]);
                min = Math.min(min, arrays[i][0]);
            }
            return result;
        }
    }
    

  • 0

    @Alafreulein The method interface had been changed to List<List<Integer>>. Please either reload the default code definition or change it in the function method signature.


  • 0
    S

    int maxDistance(int **array,int rows,int *clos)
    {
    int i,j,dist,max=0,min1,max1;
    for(i=0;i<rows;i++)
    {
    for(j=0;j<rows;j++)

    	{if(j!=i){
    	    int max1=array[j][0];int min1=array[i][0];
    	for(int k=0;k<*(clos+j);k++)
    		{if(*(*(array+j)+k)>max1)
    		max1=*(*(array+j)+k);
    		}
    	for(int k=0;k<*(clos+i);k++)
    		{if(*(*(array+i)+k)<min1)
    		min1=*(*(array+i)+k);
    		}
    		if(max1-min1>=0)
    		dist=max1-min1;
    		else
    		dist=min1-max1;	
    		
    		if(dist>max)
    		max=dist;	}
    	}
    }
    return max;
    

    }
    my c code thats a right code ? could u see it? its right but time limit is over while running this code for larger numbers of array!


Log in to reply
 

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