(转) External Sort

我觉得这个是讲External Sort的文章中,最容易看懂的文章 http://faculty.simpson.edu/lydia.sinapova/www/cmsc250/LN250_Weiss/L17-ExternalSortEX1.htm CC as below: ...

2015-12-15 04:32:25

阅读数:1512

评论数:0

Java菜鸟入门(21) Merge K sorted List

假设输入是K个iterator, 如何来merge这K个iterator of Integer,使得输出是 List? 1. 类似Merge K sorted List普通题的思路,使用PriorityQueue(or, Heap 2. 使用一个wrapper来把current Integer v...

2015-12-14 18:00:35

阅读数:795

评论数:0

Java菜鸟入门(20) Producer Consumer经典代码

来自oracle官网 https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/locks/Condition.html class BoundedBuffer { final Lock lock = new Reent...

2015-12-13 07:32:23

阅读数:1030

评论数:0

LeeCode(149) Max Points on a Line

题目如下: Given n points on a 2D plane, find the maximum number of points that lie on the same straight line. 分析如下: 思路比较直接,对其中某一个点i, 找到点i和剩下的所有n -...

2015-12-11 12:19:51

阅读数:641

评论数:0

LeetCode(269) Alien Dictionary (Java)

题目如下: There is a new alien language which uses the latin alphabet. However, the order among letters are unknown to you. You receive a list of words ...

2015-11-25 18:58:18

阅读数:3012

评论数:0

JAVA菜鸟入门 (19) inner calss: static v.s. non-static在main中被实例化时的区别

1.  首先, class中的class粗略地分成2类, static v.s non-static."Nested classes are divided into two categories: static and non-static. Nested classes that a...

2015-10-29 16:53:26

阅读数:844

评论数:0

LintCode Number of Airplanes in the Sky(Java)

题目如下: Given an interval list which are flying and landing time of the flight. How many airplanes are on the sky at most? Have you met this question i...

2015-10-12 02:07:43

阅读数:1944

评论数:0

How to first sort by one attribute, if equal, then sort by another attribute.

这个小代码来demo一下,如何来按照两个字段进行sort。  场景1 有一个list of  classes,每个class中的attribute 1是String name, attribute 2是  Int age。现在假设需求是先按照name 字母顺序升序排序,加入两个人同名同姓,再按照a...

2015-09-28 13:12:21

阅读数:496

评论数:0

Trie相关的一些题目[draft]

关于trie的定义和图形请先看这里的简短描述。下面列出它相关的一些基本操作。 1. build a trie 这是基本操作,建立一个trie,add a word, search for that word, 正好有道题目在Leetcode上. class TrieNode { // In...

2015-09-27 15:15:38

阅读数:796

评论数:0

LeetCode 分类整理(01) DFS 草稿

subset // solution 2 version B // a slightly different version from version A. // make a slight optimization while doing right shift. public c...

2015-08-31 15:46:44

阅读数:813

评论数:0

LeetCode(078) Subsets (Java)

题目如下:Given a set of distinct integers, nums, return all possible subsets. Note: Elements in a subset must be in non-descending order. The solution...

2015-07-02 13:54:17

阅读数:851

评论数:0

JAVA菜鸟入门(18) Set的Iterator

1. 使用iterator遍历Set中元素 public class SetIteratorDemo { public static void main(String[] args) { HashSet objectSet = new HashSet(); objectSet.add(&...

2015-06-23 15:03:43

阅读数:3152

评论数:0

JAVA菜鸟入门(17) 有排序的TreeSet和无排序的HashSet, LinkedHashSet

General-Purpose Set Implementations There are three general-purpose Set implementations — HashSet, TreeSet, and LinkedHashSet. Which of these three...

2015-06-22 01:51:42

阅读数:564

评论数:0

JAVA菜鸟入门(16) callback函数

Java中的callback函数, template: interface CallBack { void methodToCallBack(); } class CallBackImpl implements CallBack { public void methodToCal...

2015-05-21 01:24:56

阅读数:771

评论数:0

SumOfNestedList

get sum of NestedList是一道非常有名非常高频的的电面题 /**  * Given a nested list of integers, returns the sum of all integers in the list weighted by their depth  ...

2015-05-18 15:30:54

阅读数:841

评论数:0

JAVA菜鸟入门(15) static method/ field与normal method/field的相互调用关系

1.   normal method uses static field => fine public class StaticFieldDemo { public static int staticVar; public int instanceVar; /* * test...

2015-05-18 14:44:43

阅读数:1179

评论数:0

JAVA菜鸟入门(14) Anonymous Class 和 final variable

Anonymous Class在使用外面的local variable的时候,要declare为final,否则会有compiler error. import javax.swing.JButton; import javax.swing.JTextField; public class He...

2015-05-09 06:51:07

阅读数:810

评论数:0

JAVA菜鸟入门(13) outer class与inner class的之间能互相使用field或者method吗?

Nested classes are divided into two categories: static and non-static.  1. Nested classes that are declared static are called static nested classes....

2015-05-01 04:44:46

阅读数:1963

评论数:0

JAVA菜鸟入门(12) reference variable是气球的线 +JVM中怎么实现

1 如果variable是primitive,那就拷贝原来变量的值到新变量。 2 如果variable是object referece, 那就拷贝原来reference的值到新的变量,所以就有2个reference varibal指向了相同的object. eg.  // Before the m...

2015-04-28 23:42:42

阅读数:2210

评论数:0

JAVA菜鸟入门(11) 基本类型

一. 基本类型 Java 基础数据类型 byte (number, 1 byte) short (number, 2 bytes) int (number, 4 bytes) long (number, 8 bytes) float (float number, 4 bytes...

2015-04-26 01:11:03

阅读数:830

评论数:0

提示
确定要删除当前文章?
取消 删除
关闭
关闭