摘要:        
简单题。从尾巴开始往前就行了。public class Solution { public void merge(int A[], int m, int B[], int n) { // Start typing your Java solution below // DO NOT write main() function int len = m + n; int i = m - 1; int j = n - 1; int k = len - 1; while (i >= ...    阅读全文
posted @ 2013-08-10 10:37
阿牧遥
阅读(202)
评论(0)
推荐(0)
        
            
        
        
摘要:        
此题甚难。后来看了参考才做出来的。基本的思路就是,在递归中计算包含该root的最大值并更新至max[0](Java无法按引用传,就只能建立一个数组or something)。包含该root的最大值有如下几种可能:1.root本身;2.root和左子树中一条路径;3.root和右子树中一条路径;4.左子树一条路径和root和右子树一条路径。其中取最大就可更新至max[0]其中1,2,3可用来计算上一级的root的最大值,所以要传回去。最终,对于最上层的root来说,数内的最大路径不一定要经过根,但由于每个节点都遍历到,其最大值已经存在max[0]里面了。/** * Definition for     阅读全文
posted @ 2013-08-10 10:24
阿牧遥
阅读(1391)
评论(0)
推荐(0)
        
 
                     
                    
                 
                    
                
 
         浙公网安备 33010602011771号
浙公网安备 33010602011771号