2014年10月12日

Lowest Common Ancestor of a Binary Tree Part

摘要: bottom-uppackage test.ui;import java.util.HashSet;import java.util.Set;public class test { //unsigned 2^32-1 so we need a long to instead. pub... 阅读全文

posted @ 2014-10-12 05:51 brave_bo 阅读(167) 评论(0) 推荐(0)

Balanced Binary Tree

摘要: /** * Definition for binary tree * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; ... 阅读全文

posted @ 2014-10-12 05:33 brave_bo 阅读(201) 评论(0) 推荐(0)

Lowest Common Ancestor of a Binary Tree Part I

摘要: 456789101112131415161718192021// Return #nodes that matches P or Q in the subtree.int countMatchesPQ(Node *root, Node *p, Node *q) { if (!root) retur... 阅读全文

posted @ 2014-10-12 05:18 brave_bo 阅读(177) 评论(0) 推荐(0)

Splitting Linked List

摘要: This is a very good linked list question, as there are tricky cases you have to consider, and getting them all right in one place is harder than it lo... 阅读全文

posted @ 2014-10-12 04:17 brave_bo 阅读(200) 评论(0) 推荐(0)

Number of 1 bits

摘要: Brute force solution:Iterate 32 times, each time determining if the ith bit is a ’1′ or not. This is probably the easiest solution, and the interviewe... 阅读全文

posted @ 2014-10-12 04:07 brave_bo 阅读(310) 评论(0) 推荐(0)

导航