计数排序and基数排序
摘要:1 计数排序,稳定 复杂度o(k + n) public static int[] countingSort(int[] nums) { int n = nums.length; int k = 0; for (int i = 0; i < n; i++) { k = Math.max(k, num
阅读全文
posted @
2017-09-17 10:24
wheleetcode
阅读(194)
推荐(0)
动态规划
摘要:Matrix DP 1 Triangle public int minimumTotal(int[][] triangle) { if (triangle == null || triangle.length == 0) { return 0; } if (triangle.length == 1)
阅读全文
posted @
2017-08-28 17:37
wheleetcode
阅读(146)
推荐(0)
数据结构
摘要:1 Min Stack public class MinStack { private Stack<Integer> stack = new Stack(); private Stack<Integer> min = new Stack(); public MinStack() { // do in
阅读全文
posted @
2017-08-27 23:33
wheleetcode
阅读(130)
推荐(0)
BFS vs DFS
摘要:1 Clone Graph 1 copy ervery nodes by bfs 2 add neighbors public UndirectedGraphNode cloneGraph(UndirectedGraphNode node) { if (node == null) { return
阅读全文
posted @
2017-08-27 15:24
wheleetcode
阅读(184)
推荐(0)
子集和排列
摘要:1 Subsets public List<List<Integer>> subsets(int[] nums) { List<List<Integer>> result = new ArrayList<>(); if (nums.length == 0) { return result; } Ar
阅读全文
posted @
2017-08-26 20:20
wheleetcode
阅读(160)
推荐(0)
章三 链表
摘要:public ListNode reverse(ListNode head) { // write your code here ListNode pre = null; while (head != null) { ListNode temp = head.next; head.next = pr
阅读全文
posted @
2017-08-26 17:07
wheleetcode
阅读(131)
推荐(0)
章二 二分查找
摘要:1 二分查找 public int binarySearch(int[] nums, int target) { //write your code here if (nums.length == 0) return -1; int start = 0; int end = nums.length
阅读全文
posted @
2017-08-25 17:00
wheleetcode
阅读(140)
推荐(0)
章三 二叉树和分制
摘要:1 前序遍历三种方式 非递归 1 public ArrayList<Integer> preorderTraversal(TreeNode root) { // write your code here ArrayList<Integer> res = new ArrayList<Integer>(
阅读全文
posted @
2017-08-25 15:05
wheleetcode
阅读(167)
推荐(0)