更新代码
This commit is contained in:
parent
dde4adc4d8
commit
273aeaa5d8
@ -1,6 +1,9 @@
|
||||
package com.raorao.java;
|
||||
|
||||
import clojure.lang.Obj;
|
||||
import com.google.common.collect.HashBasedTable;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.Hashtable;
|
||||
@ -9,7 +12,7 @@ import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
public class Test {
|
||||
public class Test implements Serializable {
|
||||
|
||||
static int a;
|
||||
static int c;
|
||||
|
32
code/src/main/java/com/raorao/java/althorithm/Hanuota.java
Normal file
32
code/src/main/java/com/raorao/java/althorithm/Hanuota.java
Normal file
@ -0,0 +1,32 @@
|
||||
package com.raorao.java.althorithm;
|
||||
|
||||
import java.util.Stack;
|
||||
|
||||
/**
|
||||
* 汉诺塔问题.
|
||||
*
|
||||
* 描述:三个柱子,其中一个柱子有N个盘子,要求移动到另外一个盘子上。
|
||||
*
|
||||
* @author Xiong Raorao
|
||||
* @since 2018-08-17-16:41
|
||||
*/
|
||||
public class Hanuota {
|
||||
|
||||
static int count = 0;
|
||||
|
||||
public static void main(String[] args) {
|
||||
move(3, "A", "B", "C");
|
||||
System.out.println("times: " + count);
|
||||
}
|
||||
|
||||
public static void move(int n, String A, String B, String C) {
|
||||
if (n == 1) {
|
||||
System.out.println(A + " ==> " + C);
|
||||
count++;
|
||||
return;
|
||||
}
|
||||
move(n - 1, A, C, B);
|
||||
move(1, A, B, C);
|
||||
move(n - 1, B, A, C);
|
||||
}
|
||||
}
|
39
code/src/main/java/com/raorao/leetcode/q167/TwoSum.java
Normal file
39
code/src/main/java/com/raorao/leetcode/q167/TwoSum.java
Normal file
@ -0,0 +1,39 @@
|
||||
package com.raorao.leetcode.q167;
|
||||
|
||||
/**
|
||||
* 有序数组的和.
|
||||
*
|
||||
* @author Xiong Raorao
|
||||
* @since 2018-08-17-17:38
|
||||
*/
|
||||
public class TwoSum {
|
||||
|
||||
public static void main(String[] args) {
|
||||
int[] numbers = {2, 7, 11, 15};
|
||||
int target = 9;
|
||||
int[] res = twoSum(numbers, target);
|
||||
System.out.println(res[0] + " " + res[1]);
|
||||
}
|
||||
|
||||
public static int[] twoSum(int[] numbers, int target) {
|
||||
if (numbers == null || numbers.length == 0) {
|
||||
return new int[0];
|
||||
}
|
||||
int[] res = new int[2];
|
||||
int size = numbers.length;
|
||||
int low = 0;
|
||||
int high = size - 1;
|
||||
while (low < high) {
|
||||
if (numbers[low] + numbers[high] == target) {
|
||||
res[0] = low + 1;
|
||||
res[1] = high + 1;
|
||||
break;
|
||||
} else if (numbers[low] + numbers[high] < target) {
|
||||
low++;
|
||||
} else {
|
||||
high--;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
18
code/src/main/java/com/raorao/leetcode/q406/Solution.java
Normal file
18
code/src/main/java/com/raorao/leetcode/q406/Solution.java
Normal file
@ -0,0 +1,18 @@
|
||||
package com.raorao.leetcode.q406;
|
||||
|
||||
/**
|
||||
* 根据身高和序号重组队列.
|
||||
*
|
||||
* @author Xiong Raorao
|
||||
* @since 2018-08-17-15:22
|
||||
*/
|
||||
public class Solution {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
}
|
||||
|
||||
public int[][] reconstructQueue(int[][] people) {
|
||||
return null;
|
||||
}
|
||||
}
|
@ -4,7 +4,7 @@ import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
|
||||
/**
|
||||
* 题目描述:计算让一组区间不重叠所需要移除的区间个数.
|
||||
* 题目描述:计算让一组区间不重叠所需要移除的最少区间个数.
|
||||
*
|
||||
* 贪心策略:计算最多能组成的不重叠区间个数,然后用区间总个数减去不重叠区间的个数。
|
||||
*
|
||||
|
48
code/src/main/java/com/raorao/leetcode/q452/Solution.java
Normal file
48
code/src/main/java/com/raorao/leetcode/q452/Solution.java
Normal file
@ -0,0 +1,48 @@
|
||||
package com.raorao.leetcode.q452;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
|
||||
/**
|
||||
* 用最少数量的箭引爆气球.
|
||||
*
|
||||
* 思路:其实和计算不重叠区间的是一样的,
|
||||
*
|
||||
* @author Xiong Raorao
|
||||
* @since 2018-08-17-14:53
|
||||
*/
|
||||
public class Solution {
|
||||
|
||||
public int findMinArrowShots(int[][] points) {
|
||||
if (points == null || points.length == 0) {
|
||||
return 0;
|
||||
}
|
||||
Point[] p = new Point[points.length];
|
||||
for (int i = 0; i < points.length; i++) {
|
||||
p[i] = new Point(points[i][0], points[i][1]);
|
||||
}
|
||||
Arrays.sort(p, Comparator.comparingInt(e -> e.end));
|
||||
int count = 1;
|
||||
int lastEnd = p[0].end;
|
||||
for (int i = 1; i < p.length; i++) {
|
||||
if (p[i].start <= lastEnd) {
|
||||
continue;
|
||||
}
|
||||
lastEnd = p[i].end;
|
||||
count++;
|
||||
}
|
||||
return p.length - count;
|
||||
}
|
||||
|
||||
static class Point {
|
||||
|
||||
int start;
|
||||
int end;
|
||||
|
||||
|
||||
public Point(int start, int end) {
|
||||
this.start = start;
|
||||
this.end = end;
|
||||
}
|
||||
}
|
||||
}
|
@ -2,9 +2,6 @@
|
||||
|
||||
目标职位: java 工程师、大数据开发方向
|
||||
|
||||
[简历](熊饶饶-校招简历-0717.pdf)
|
||||
[头像](我的头像.jpg)
|
||||
|
||||
## 1. 招聘信息
|
||||
|
||||
招聘信息的来源主要是学校的群和牛客网。
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 30 KiB |
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user