摘要: public static void main(String[] args) { System.out.println(GetInsertLocation(new int[]{0,2},-1)); System.out.println(GetInsertLocati... 阅读全文
posted @ 2015-01-11 04:40 新一代的天皇巨星 阅读(137) 评论(0) 推荐(0)
摘要: Suppose you are a fan of auto-racing and want to figure out which drivers are likely to perform well in an upcoming race. Luckily you have access to a... 阅读全文
posted @ 2015-01-11 04:38 新一代的天皇巨星 阅读(439) 评论(0) 推荐(0)
摘要: G(V,E,W), E~O(V^2) for complete graphOrder of graph: VSize of graph: EComplete graph: has one edge between each pair of vertices.Simple graph: has at ... 阅读全文
posted @ 2015-01-09 01:03 新一代的天皇巨星 阅读(160) 评论(0) 推荐(0)
摘要: Description: Count the number of prime numbers less than a non-negative number, n. Credits:Special thanks to @mithmatt for adding this problem and cre 阅读全文
posted @ 2015-01-09 00:21 新一代的天皇巨星 阅读(262) 评论(0) 推荐(0)
摘要: Heap(An array visualized as a complete binary tree):Heap Operations:Insert, O(log(n)) Add it to the end of the tree and bubbl... 阅读全文
posted @ 2015-01-05 09:31 新一代的天皇巨星 阅读(329) 评论(0) 推荐(0)
摘要: Good for array and linked list. Stable Sort.Time Complexity: Best, Average, Worst => O(nlogn);Space Complexity: O(n), in-place merge sort makes it ver... 阅读全文
posted @ 2015-01-04 12:32 新一代的天皇巨星 阅读(276) 评论(0) 推荐(0)
摘要: Insertion Sort:Time Complexity: Best O(n) (when already sorted); Average O(n^2); Worst O(n^2).Space Complexity: O(1) public static void main(String... 阅读全文
posted @ 2015-01-04 10:11 新一代的天皇巨星 阅读(244) 评论(0) 推荐(0)
摘要: Algorithm 1:public static void main(String[] args) { int[] a = new int[]{1,2,3,4,5,6,7,8,9,10,11,12}; shiftN2(a, 1); System.ou... 阅读全文
posted @ 2015-01-04 07:23 新一代的天皇巨星 阅读(197) 评论(0) 推荐(0)
摘要: 多说无益,直接看代码。public class MyTest { public static void main(String[] args) { Test t1 = new Test(); System.out.println("------------")... 阅读全文
posted @ 2015-01-03 10:24 新一代的天皇巨星 阅读(643) 评论(0) 推荐(0)
摘要: In C# we have ref and out, while in Java we don't.To do something similar to ref, there are normally 4 ways.Check this out:http://stackoverflow.com/qu... 阅读全文
posted @ 2015-01-02 01:21 新一代的天皇巨星 阅读(204) 评论(0) 推荐(0)