随笔分类 -  九章强化

强化第一章
摘要:1 Two Sum public int[] twoSum(int[] numbers, int target) { int[] res = {-1, -1}; if (numbers == null || numbers.length < 2) { return res; } Map<Intege 阅读全文
posted @ 2017-09-02 10:54 wheleetcode 阅读(100) 评论(0) 推荐(0)
双指针
摘要:两根指 针1. 一个数组,从两边往中间移动(对撞型)2. 一个数组,同时向前移动(前向型)3. 两个数组(并行型) 对 撞型或者相会型 Two sum 类 和 Partition 类 1 Two Sum public int[] twoSum(int[] numbers, int target) { 阅读全文
posted @ 2017-09-01 14:28 wheleetcode 阅读(175) 评论(0) 推荐(0)
数据结构强化1
摘要:Union Find 集合合并,查找元素在集合里面 数组实现 int[] pre; public int find(int x) { int r = x; while (r != pre[r]) { r = pre[r]; } int i = x, j; while (pre[i] != r) { 阅读全文
posted @ 2017-08-31 11:51 wheleetcode 阅读(243) 评论(0) 推荐(0)
动态规划强化
摘要:动态规划空间优化 滚动数组 1 House Robber public long houseRobber(int[] a) { if (a == null || a.length == 0) { return 0; } if (a.length == 1) { return a[0]; } if ( 阅读全文
posted @ 2017-08-31 09:32 wheleetcode 阅读(187) 评论(0) 推荐(0)