摘要: Problem: Given a two-dimensional graph with points on it, find a line which passes the most number of points.此题是Cracking the code 5th edition 第七章第六题,思... 阅读全文
posted @ 2014-05-28 12:22 门对夕阳 阅读(600) 评论(1) 推荐(0) 编辑
摘要: The tricky thing is how to decide the key for a hashmap. Especially when you intend to use self-defined objects as key.If you want to make two differe... 阅读全文
posted @ 2014-05-28 11:32 门对夕阳 阅读(173) 评论(0) 推荐(0) 编辑
摘要: 今天发现一小技巧,关于如何把Eclipse的某一个Existing project push 到github服务器。Eclipse 应该是 JavaEE 版本。在project 右键 team, git 什么的commit一下。目的是生成 local repository。然后去打开windows版... 阅读全文
posted @ 2014-05-27 04:44 门对夕阳 阅读(1915) 评论(0) 推荐(0) 编辑
摘要: 在Eclipse里初次使用Maven,右键project->add dependency, 发现search不管用,这时候需要按照以下步骤操作:Goto "Preferences -> Maven"Check"Download repository index updates on start"an... 阅读全文
posted @ 2014-05-23 15:10 门对夕阳 阅读(278) 评论(0) 推荐(0) 编辑
摘要: 给一个Binary Tree,检查是不是Binary Search Tree. 即是否满足对每个节点,左子树的中的所有节点的值 = root.val){ // only 'Less than' is valid return false; } ... 阅读全文
posted @ 2014-05-04 07:26 门对夕阳 阅读(370) 评论(0) 推荐(0) 编辑
摘要: 问题:给一个二叉树,写一个算法判断这个树是不是balanced。Solution #1.第一次遇到这个问题时我的解法,如下:public class Solution { public boolean isBalanced(TreeNode root) { if(root == ... 阅读全文
posted @ 2014-05-04 00:58 门对夕阳 阅读(6649) 评论(2) 推荐(1) 编辑
摘要: To center all elements within a div:To center a div itself: 阅读全文
posted @ 2014-04-27 03:43 门对夕阳 阅读(141) 评论(0) 推荐(0) 编辑
摘要: 最近在做Database课程的final project,foodiePharos, 重新认识了JSP里容易出现的一些问题。比如我们这个项目使用了JPA,就涉及到entity对象的状态问题,EntityManager persiste/merge后的entity是managed,但是如果这时把对象放... 阅读全文
posted @ 2014-04-21 12:25 门对夕阳 阅读(163) 评论(0) 推荐(0) 编辑
摘要: This algorithm deals with the general case, where G is a directed, weight graph, and it can contains negative edge weigths, cycles and even negative-w... 阅读全文
posted @ 2014-04-14 06:05 门对夕阳 阅读(579) 评论(0) 推荐(0) 编辑
摘要: 描述给你一个m x n (1 <= m, n <= 100)的矩阵A (0<=aij<=10000),要求在矩阵中选择一些数,要求每一行,每一列都至少选到了一个数,使得选出的数的和尽量的小。思路:这个题用DP做不了,因为Solution的结构不具备Optimal Substructure, 比如1 100 1001 100 100100 1 1Solution是1+1+1+1 = 4,但是该矩阵的子矩阵100 1001 1的Solution是 100+1 = 101. 看来只能用DFS做了。 阅读全文
posted @ 2014-04-13 10:26 门对夕阳 阅读(1537) 评论(0) 推荐(0) 编辑