2018年8月27日

摘要: 拓扑排序的问题 套路: 1. 初始化所有的节点的入度为零。 2. 遍历给定的输入要求。 维护一个indegree 的表。记录每个节点的入度。 维护map, 每个节点的后续节点 3. 得到这两个表以后开始用queue遍历所有入度为零的点。 4. **如何判断最终结果? 由于我们开始初始化了所有节点入度 阅读全文
posted @ 2018-08-27 14:00 葫芦胡同749 阅读(96) 评论(0) 推荐(0) 编辑
摘要: https://leetcode.com/problems/integer-to-english-words/description/ 要求把一个数字转换成英语。 1,000,000,000,000 想到没三位可以成一组,每组内的形成方式是一样的。只是最后加的千位符号不一样 -- "","Thous 阅读全文
posted @ 2018-08-27 12:40 葫芦胡同749 阅读(113) 评论(0) 推荐(0) 编辑
摘要: *** Do I need to consider multi-threading?*** HashMap等数据结构都不支持多线程。 都是non-Sychronized 如果要支持muti-thread就要加sychronization. 简单来说就是加锁 ConcurrentHashMap - 用 阅读全文
posted @ 2018-08-27 10:30 葫芦胡同749 阅读(372) 评论(0) 推荐(0) 编辑
摘要: public String alienOrder(String[] words) { //because the char has a topological order, we record how many char to current char // a (b ,c, d) after it // b (c ,d ) after it ... 阅读全文
posted @ 2018-08-27 10:10 葫芦胡同749 阅读(110) 评论(0) 推荐(0) 编辑

导航