摘要: 利用LCS求出最长公共子串即可 阅读全文
posted @ 2017-11-24 17:40 hudiwei-hdw 阅读(374) 评论(0) 推荐(0) 编辑
摘要: Problem description Given a matrix consists of 0 and 1, find the distance of the nearest 0 for each cell. The distance between two adjacent cells is 1 阅读全文
posted @ 2017-06-20 16:08 hudiwei-hdw 阅读(275) 评论(0) 推荐(0) 编辑
摘要: You have a total of n coins that you want to form in a staircase shape, where every k-th row must have exactly k coins. Given n, find the total number 阅读全文
posted @ 2017-04-14 15:45 hudiwei-hdw 阅读(218) 评论(0) 推荐(0) 编辑
摘要: 单例模式是设计模式中用得比较多的一种设计模式,它的主要优点有: 1.访问受控,保证访问的是唯一的实例。 2.由于只有一个实例,所以节省资源。 缺点: 灵活性低,如果对象的应用场景多变,则不适用单例模式。 1.如何实现单例模式? 1.1 懒汉模式(线程不安全) 想要实现单例,莫非就是要适用static 阅读全文
posted @ 2017-03-22 17:34 hudiwei-hdw 阅读(1902) 评论(0) 推荐(0) 编辑
摘要: 并发编程,是老生常谈的问题了,并发编程能够真正的让多核cpu发挥最大的优势。 现在我们来玩一下Java Fork/join 并发编程模型^_^ Fork/Join框架是Java7提供的一个用于并行计算的框架,它主要是用于把一个大任务拆分为若干个小任务,然后把若干个小任务的结果再汇总为大任务的结果。 阅读全文
posted @ 2017-03-13 18:45 hudiwei-hdw 阅读(2196) 评论(0) 推荐(0) 编辑
摘要: 相信对于使用过Java的人来说,ArrayList这个类大家一定不会陌生。 数据结构课上讲过, Array是数组,它能根据下标直接找到相应的地址,所以索引速度很快,但是唯一的缺点是不能动态改变数组的长度,复杂度O(1)。 而List就是链表,它搜索相应地址都只能从链表头部一个一个找下去,直至找到对应 阅读全文
posted @ 2017-03-10 15:39 hudiwei-hdw 阅读(896) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level). For example:Given binary tree [3 阅读全文
posted @ 2017-03-06 10:46 hudiwei-hdw 阅读(150) 评论(0) 推荐(0) 编辑
摘要: 120. Triangle Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below. For example 阅读全文
posted @ 2017-03-01 17:28 hudiwei-hdw 阅读(208) 评论(0) 推荐(0) 编辑
摘要: Problem Description 最后的挑战终于到了!站在yifenfei和MM面前的只剩下邪恶的大魔王lemon一人了!战胜他,yifenfei就能顺利救出MM。Yifenfei和魔王lemon的挑战很简单:由lemon给出三个字符串,然后要yifenfei说出第一串的某个子串,要求该子串长 阅读全文
posted @ 2017-01-10 11:45 hudiwei-hdw 阅读(207) 评论(0) 推荐(0) 编辑
摘要: Given a string, find the length of the longest substring without repeating characters. Examples: Given "abcabcbb", the answer is "abc", which the leng 阅读全文
posted @ 2016-11-04 16:37 hudiwei-hdw 阅读(139) 评论(0) 推荐(0) 编辑