顺丰科技
有大佬能看看第二题哪儿出问题了吗。
public static int process(Map<Integer,List<Integer>> map,int[] fenshu,int cur){ //这个节点没有任何子节点 if(!map.containsKey(cur)){ int t = fenshu[cur]; finalRes += Math.abs(t); return -t; } //当前有子节点 List<Integer> list = map.get(cur); int curFenshu = fenshu[cur]; for(Integer i : list){ curFenshu += process(map,fenshu,i); } finalRes += Math.abs(curFenshu); return -1 * curFenshu; }Key是节点,value是节点的字节点序列