04 2014 档案

摘要:To center all elements within a div:To center a div itself: 阅读全文
posted @ 2014-04-27 03:43 门对夕阳 阅读(146) 评论(0) 推荐(0)
摘要:最近在做Database课程的final project,foodiePharos, 重新认识了JSP里容易出现的一些问题。比如我们这个项目使用了JPA,就涉及到entity对象的状态问题,EntityManager persiste/merge后的entity是managed,但是如果这时把对象放... 阅读全文
posted @ 2014-04-21 12:25 门对夕阳 阅读(166) 评论(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 门对夕阳 阅读(583) 评论(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)
摘要:We know that the longest path problem for general case belongs to the NP-hard category, so there is no known polynomial time solution for it. However, for a special case which is directed acyclic graph, we can solve this problem in linear time.First, take a look at an algorithm that sloves the short 阅读全文
posted @ 2014-04-12 07:20 门对夕阳 阅读(333) 评论(0) 推荐(0)
摘要:We all know that the shortest path problem has optimal substructure. The reasoning is like below:Supppose we have a path p from node u to v, another node t lies on path p: u->t->v ("->" means a path).We claim that u->t is also a shortest path from u to t, and t->v is a short 阅读全文
posted @ 2014-04-12 06:45 门对夕阳 阅读(246) 评论(0) 推荐(0)
摘要:Problem:此题的做法和 “检查单链表回文” 那道题的骨架是一样的,用 Recursive 的方法,简洁而优雅。参考回文那道题:http://www.cnblogs.com/Antech/p/3847752.htmlCode in Java:public class Solution { ... 阅读全文
posted @ 2014-04-12 03:08 门对夕阳 阅读(356) 评论(0) 推荐(0)
摘要:This is a simple but important algorithm when dealing with singly linked list.This algorithms can reversely access a singly linked list using O(n) time. Below is my code in Java.class Node{ Node next; int val;}class SinglyLinkedList{ Node head; Node tail; //append a new Node t... 阅读全文
posted @ 2014-04-11 05:28 门对夕阳 阅读(204) 评论(0) 推荐(0)
摘要:Problem statement:Thought: Since TreeNode has a self-recursive structure, it's very natural and easy to come up with a recursive implement. But the tricky part is how to implement this using a iterative method. The three binary tree traversal methods: pre-order, in-order and post-order can all b 阅读全文
posted @ 2014-04-10 04:41 门对夕阳 阅读(941) 评论(0) 推荐(0)
摘要:Binary Tree的三种Traversal方法老是记混,故于此总结下。Preorder: Node -> Left subtree -> Right subtreeInorder: Left subtree -> Node -> Right subtreePostorder: Left subtree -> Right subtree -> NodePre, In, Post指的是Node本身在[Node, Left, Right]中被访问的顺序。Pre is 1st, In is 2nd, Post is 3rd.Note: Inorder trave 阅读全文
posted @ 2014-04-10 03:08 门对夕阳 阅读(109) 评论(0) 推荐(0)
摘要:Problem:Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations:getandset.get(key)- Get the value (will always be positive) of the key if the key exists in the cache, otherwise return -1.set(key, value)- Set or insert the value if the key 阅读全文
posted @ 2014-04-10 02:58 门对夕阳 阅读(355) 评论(0) 推荐(0)

点击右上角即可分享
微信分享提示