移动火柴

package 快手笔试;

import java.util.Arrays;
import java.util.Scanner;

public class Solution2 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        int[] number = new int[str.length()];
        for(int i = 0; i < str.length(); i++){
            number[i] = Integer.parseInt(str.substring(i,i+1));
        }
        int[][] arr = new int[10][3];
        arr[0] = new int[]{-1,9,8};
        arr[1] = new int[]{-1,-1,7};
        arr[2] = new int[]{-1,3,-1};
        arr[3] = new int[]{-1,5,9};
        arr[4] = new int[]{-1,-1,-1};
        arr[5] = new int[]{-1,3,9};
        arr[6] = new int[]{5,9,8};
        arr[7] = new int[]{1,-1,-1};
        arr[8] = new int[]{9,-1,-1};
        arr[9] = new int[]{5,6,8};
        int result = -1;
        for(int i = 0; i < number.length; i++){
            int[] tempArray = Arrays.copyOf(number,number.length);
            if(arr[number[i]][0] == -1)
                continue;
            tempArray[i] = arr[number[i]][0];
            for(int j = 0; j 

 

你可能感兴趣的:(笔试真题)