06 2013 档案
摘要:stackoverflow: http://stackoverflow.com/questions/1838304/call-the-llvm-jit-from-c-programAnother trial under llvm 3.2;In prepared IR "tst.ll", code:; ModuleID = 'tst.bc' define i32 @add1(i32 %AnArg) { EntryBlock: %0 = add ...
阅读全文
摘要:Binary Tree Maximum Path SumGiven a binary tree, find the maximum path sum.The path may start and end at any node in the tree. For example: Given the below binary tree, 1 / \ 2 3Return 6.递归求解。maxPathSum(root)跟maxPathSum(root.left)和maxPathSum(root.right)之间的关系:root左子树的maxPath,右子树的maxP...
阅读全文
摘要:LeetCode 跟树结构相关的题目的测试用例中大多是通过String数组来构造树。例如{2,#,3,#,4,#,5,#,6},可以构造出如下的树(将树结构逆时针选择90度显示): 6 5 4 32很直观地可以理解,输入的String数组是对树结构进行“层序”遍历得到的结果。以下代码用于构造树结构,并提供printTree用于打印树结构。package util;import java.util.LinkedList;import java.util.Queue;public class util { public static class TreeNode { int val;...
阅读全文
摘要:Path Sum IIGiven a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.For example: Given the below binary tree and sum = 22, 5 / \ 4 8 / / \ 11 13 4 / \ / \ 7 2 5 1return[...
阅读全文