Link to home
Start Free TrialLog in
Avatar of chalie001
chalie001

asked on

complete the code

can you complete
 
//Compiler version 1.8.0_111
import java.util.*;
import java.lang.*;

class Solution
{
    /**
    * @param {number} src
    * @param {number} dest
    * @param {number[][]} wizards
    * @return {[[] = minCost, [] = minPath]}
    */
    
    public static int[][] distance_path (int src, int dest, int[][]wizards) {
        int result[][] = new int[2][];
        int minCost = 0;
        int[] minPath = null;
        // Put your code here to calculate minCost and minPath
        minCost = minCost + minPath; 
        minPath =  minPath + dest;

        // Return the result, do not change the structure
        result[0] = new int[]{ minCost };
        if (minPath == null) { minPath = new int[] {}; }        
        result[1] = minPath;
        return  {[result[][] = minCost, [] = minPath]};
    }
}

class Rextester
{  
    public static void main(String args[])
    {
        int numberOfWizards = 10;
        
        Scanner sc = new Scanner(System.in);
        int src = sc.nextInt();
        int dest = sc.nextInt();
        
        int matrix[][] = new int[numberOfWizards][];
        int i;
        for(i=0;i<numberOfWizards;i++){
            String line = sc.next();
            char[] ch = line.toCharArray();
            matrix[i] = new int[line.length()];            
            for(int j = 0; j < line.length(); j++) {
               matrix[i][j] = Character.getNumericValue(ch[j]);
            }
        }
        
        int[][] result = Solution.distance_path(src, dest, matrix);
        String[] sarr = Arrays.stream(result[1]).mapToObj(String::valueOf).toArray(String[]::new);
        System.out.println(String.valueOf(result[0][0]) + " " + String.join("", sarr));
    }
}

}

Open in new window


User generated image
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.