2014年1月31日

LeetCode: Symmetric Tree

摘要: Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).用递归的方法很好做。先比较对应的两个节点数值是否相同,如果相同就看第一个节点的左子和第二个节点的右子是否对称,以及第一个节点的右子和第二个节点的左子。 1 public static boolean isSymmetric(TreeNode root) { 2 if (root == null) return true; 3 else return check(root.lef... 阅读全文

posted @ 2014-01-31 01:18 longhorn 阅读(209) 评论(0) 推荐(0) 编辑

OODesign: Modelling an elevator using Object-Oriented Analysis and Design

摘要: The problem is as follows: design a basic set of objects/methods to be used to simulate an elevator bank. What are the objects and their attributes/methods?First there is an elevator class. It has a direction (up, down, stand, maintenance), a current floor and a list of floor requests sorted in the 阅读全文

posted @ 2014-01-31 00:39 longhorn 阅读(492) 评论(0) 推荐(0) 编辑

导航