01 2015 档案
摘要:Inefficient Print All/One using recursive(DFS)public static void main(String[] args) { solveSudoku(new char[N][N]); ...
阅读全文
摘要:DP = Recursion + Memoization, A Smart Brute-force Algorithm Divide the original problem into similar subproblems. Hard desgin part: what are the subpr
阅读全文
摘要:Preamble: Fibonacci Series: If n = 0: return 0;If n<=2: return 1;return f(n-1)+f(n-2) Time Complexity: It's the Fibonacci Recurrence function. T(n) =
阅读全文
摘要:public static void main(String[] args) { System.out.println(GetInsertLocation(new int[]{0,2},-1)); System.out.println(GetInsertLocati...
阅读全文
摘要: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...
阅读全文
摘要: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 ...
阅读全文
摘要: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
阅读全文
摘要: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...
阅读全文
摘要: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...
阅读全文
摘要: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...
阅读全文
摘要: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...
阅读全文
摘要:多说无益,直接看代码。public class MyTest { public static void main(String[] args) { Test t1 = new Test(); System.out.println("------------")...
阅读全文
摘要: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...
阅读全文
摘要:Normal class(Non-nested class) can only be public, abstract or final.For nested classes, static is allowed.Nested classes(private, public, protected) ...
阅读全文

浙公网安备 33010602011771号