m*****k 发帖数: 731 | 1 public static int reach(char start, char end , int steps){
HashMap keyboard = new HashMap<>();
keyboard.put('1', new int[]{0,0});
keyboard.put('2', new int[]{0,1});
keyboard.put('3', new int[]{0,2});
keyboard.put('4', new int[]{1,0});
keyboard.put('5', new int[]{1,1});
keyboard.put('6', new int[]{1,2});
keyboard.put('7', new int[]{2,0});
keyboard.put('8', new int[]{2,1});
keyboard.put('9', new int[]{2,2});
keyboard.put('*', new int[]{3,0});
keyboard.put('0', new int[]{3,1});
... 阅读全帖 |
|
m*****k 发帖数: 731 | 2 那就再加个map存中间结果不就dp了么。
public static BigInteger reach(char start, char end, int steps) {
Map keyboard = new TreeMap<>();
Map pathsMap = new HashMap<>();
keyboard.put('1', new int[] { 0, 0 });
keyboard.put('2', new int[] { 0, 1 });
keyboard.put('3', new int[] { 0, 2 });
keyboard.put('4', new int[] { 1, 0 });
keyboard.put('5', new int[] { 1, 1 });
keyboard.put('6', new int[] { 1, 2 });
keybo... 阅读全帖 |
|