diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..3425b85
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+.idea/*
+target/*
+*.iml
\ No newline at end of file
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
index fa609d6..1401148 100644
--- a/.idea/compiler.xml
+++ b/.idea/compiler.xml
@@ -1,32 +1,16 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
+
-
-
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__io_netty_netty_all_5_0_0_Alpha2.xml b/.idea/libraries/Maven__io_netty_netty_all_5_0_0_Alpha2.xml
new file mode 100644
index 0000000..c7b9c5c
--- /dev/null
+++ b/.idea/libraries/Maven__io_netty_netty_all_5_0_0_Alpha2.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__junit_junit_4_12.xml b/.idea/libraries/Maven__junit_junit_4_12.xml
new file mode 100644
index 0000000..d411041
--- /dev/null
+++ b/.idea/libraries/Maven__junit_junit_4_12.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_apiguardian_apiguardian_api_1_0_0.xml b/.idea/libraries/Maven__org_apiguardian_apiguardian_api_1_0_0.xml
new file mode 100644
index 0000000..a82457d
--- /dev/null
+++ b/.idea/libraries/Maven__org_apiguardian_apiguardian_api_1_0_0.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml b/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml
new file mode 100644
index 0000000..f58bbc1
--- /dev/null
+++ b/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index dfca8c4..5755a99 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,8 +1,5 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
- 1.8
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
index fdedb92..452c3f5 100644
--- a/.idea/modules.xml
+++ b/.idea/modules.xml
@@ -2,7 +2,7 @@
-
+
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index ecdcd4c..db7ee93 100644
--- a/pom.xml
+++ b/pom.xml
@@ -7,6 +7,115 @@
Javabasis
Javabasis
1.0-SNAPSHOT
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+ 1.8
+ 1.8
+
+
+
+
+
+<<<<<<< HEAD
+
+
+ io.netty
+ netty-all
+ 5.0.0.Alpha2
+
+
+
+ org.apache.httpcomponents
+ httpclient
+ 4.5.3
+
+
+ org.junit.jupiter
+ junit-jupiter-api
+ RELEASE
+
+
+ junit
+ junit
+ RELEASE
+
+
+
+ cglib
+ cglib
+ 3.2.5
+
+
+
+ org.springframework
+ spring-jdbc
+ 5.0.3.RELEASE
+
+=======
+
+
+ io.netty
+ netty-all
+ 5.0.0.Alpha2
+
+
+
+ org.apache.httpcomponents
+ httpclient
+ 4.5.3
+
+
+ org.junit.jupiter
+ junit-jupiter-api
+ RELEASE
+
+
+ junit
+ junit
+ RELEASE
+
+
+
+ cglib
+ cglib
+ 3.2.5
+
+
+
+ org.springframework
+ spring-jdbc
+ 5.0.3.RELEASE
+
+>>>>>>> 24b1076e7ad80d6921ddc6d64256caadbbb6ec95
+
+
+ com.alibaba
+ fastjson
+ 1.2.47
+
+
+
+ com.fasterxml.jackson.core
+ jackson-core
+ 2.9.4
+
+
+
+ com.fasterxml.jackson.core
+ jackson-databind
+ 2.9.4
+
+
+
+ org.javassist
+ javassist
+ 3.22.0-GA
+
+
\ No newline at end of file
diff --git a/src/main/java/ExceptionAndError/TestErroe.java b/src/main/java/ExceptionAndError/TestErroe.java
new file mode 100644
index 0000000..4b49c20
--- /dev/null
+++ b/src/main/java/ExceptionAndError/TestErroe.java
@@ -0,0 +1,33 @@
+package ExceptionAndError;
+
+/**
+ * @author szh
+ * @create 2018-05-25 16:08
+ **/
+public class TestErroe {
+ Runnable runnable =new Runnable() {
+ @Override
+ public void run() {
+ for(int i =0 ;i< 100000 ;i++){
+// if(i>50){
+// try {
+// Thread.currentThread().sleep(1000);
+// } catch (InterruptedException e) {
+// e.printStackTrace();
+// }
+// }
+ }
+ }
+ };
+ private void startThread(){
+ Thread thread =new Thread(runnable);
+ thread.start();
+ thread.stop();
+ }
+
+ public static void main(String[] args) {
+ TestErroe testErroe =new TestErroe();
+ testErroe.startThread();
+ Thread.currentThread();
+ }
+}
diff --git a/src/main/java/Interesting/ADDTest.class b/src/main/java/Interesting/ADDTest.class
new file mode 100644
index 0000000..01da6fc
Binary files /dev/null and b/src/main/java/Interesting/ADDTest.class differ
diff --git a/src/main/java/Interesting/ADDTest.java b/src/main/java/Interesting/ADDTest.java
new file mode 100644
index 0000000..cce522f
--- /dev/null
+++ b/src/main/java/Interesting/ADDTest.java
@@ -0,0 +1,15 @@
+package Interesting;
+
+
+/**
+ * @author szh
+ * @create 2018-06-06 20:30
+ **/
+public class ADDTest {
+ public static void main(String[] args) {
+ int a=6,b;
+ b=(++a)+(++a)+(++a);
+ System.out.println(b);
+ System.out.println(a);
+ }
+}
diff --git a/src/main/java/Leetcode/AssignCookies.java b/src/main/java/Leetcode/AssignCookies.java
new file mode 100644
index 0000000..2175c4e
--- /dev/null
+++ b/src/main/java/Leetcode/AssignCookies.java
@@ -0,0 +1,25 @@
+package Leetcode;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author szh
+ * @create 2018-08-31 22:40
+ **/
+public class AssignCookies {
+ public int findContentChildren(int[] g, int[] s) {
+ Map map =new HashMap<>();
+ for(int i : g){
+ map.put(i,map.get(i) == null? 1: map.get(i)+1);
+ }
+ int result=0;
+ for(int i :s){
+ if(map.get(i) != null && map.get(i) !=0){
+ map.put(i,map.get(i)-1);
+ result++;
+ }
+ }
+ return result;
+ }
+}
diff --git a/src/main/java/Leetcode/BackspaceStringCompare.java b/src/main/java/Leetcode/BackspaceStringCompare.java
new file mode 100644
index 0000000..babb7ee
--- /dev/null
+++ b/src/main/java/Leetcode/BackspaceStringCompare.java
@@ -0,0 +1,47 @@
+package Leetcode;
+
+import java.util.LinkedList;
+import java.util.Queue;
+import java.util.Stack;
+
+/**
+ * @author szh
+ * @create 2018-09-17 21:10
+ **/
+public class BackspaceStringCompare {
+ public static void main(String[] args) {
+ new BackspaceStringCompare().backspaceCompare("ab#c","ad#c");
+ }
+ public boolean backspaceCompare(String S, String T) {
+ Stack SU = new Stack<>();
+ Stack TU = new Stack<>();
+ char[] s1 =S.toCharArray();
+ char[] t1 =T.toCharArray();
+ for(int i =0 ; i < s1.length ;i++){
+ if(s1[i] == '#'){
+ if(!SU.isEmpty()){
+ SU.pop();
+ }
+ }else{
+ SU.add(s1[i]);
+ }
+ }
+ for(int i =0 ; i < t1.length ;i++){
+ if(t1[i] == '#'){
+ if(!TU.isEmpty()){
+ TU.pop();
+ }
+ }else{
+ TU.add(t1[i]);
+ }
+ }
+ while(!SU.isEmpty() && !TU.isEmpty()){
+ if(SU.pop() == TU.pop()){
+ continue;
+ }else{
+ return false;
+ }
+ }
+ return SU.isEmpty() && TU.isEmpty() ? true :false;
+ }
+}
diff --git a/src/main/java/Leetcode/ContainsDuplicate.java b/src/main/java/Leetcode/ContainsDuplicate.java
new file mode 100644
index 0000000..1d3534f
--- /dev/null
+++ b/src/main/java/Leetcode/ContainsDuplicate.java
@@ -0,0 +1,30 @@
+package Leetcode;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * @author szh
+ * @create 2018-08-19 14:51
+ **/
+public class ContainsDuplicate {
+ public boolean containsDuplicate(int[] nums) {
+ // for(int i =0 ;i set =new HashSet<>();
+ for(int i=0 ;i five =new Stack<>();
+ Stack ten =new Stack<>();
+ int[] money =new int[bills.length];
+ for(int i =0 ;i<=bills.length ;i++){
+ if(bills[i] == 5){
+ five.push(bills[i]);
+ }
+ if(bills[i] == 10){
+ ten.push(bills[i]);
+ if(five.size() == 0){
+ return false;
+ }
+ five.pop();
+ }
+ if(bills[i] == 20){
+ if(five.size() == 0){
+ return false;
+ }
+ if(ten.size() == 0){
+ if(five.size() >=3){
+ five.pop();
+ five.pop();
+ five.pop();
+ }else{
+ return false;
+ }
+ }else{
+ ten.pop();
+ five.pop();
+ }
+ }
+ }
+ return true;
+ }
+
+ public static void main(String[] args) {
+ int[] a= new int[]{5,5,5,10,5,5,10,20,20,20};
+ new LemonadeChange().lemonadeChange(a);
+ }
+}
diff --git a/src/main/java/Leetcode/MaxAreaofIsland.java b/src/main/java/Leetcode/MaxAreaofIsland.java
new file mode 100644
index 0000000..18157b8
--- /dev/null
+++ b/src/main/java/Leetcode/MaxAreaofIsland.java
@@ -0,0 +1,49 @@
+package Leetcode;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author szh
+ * @create 2018-06-14 18:53
+ **/
+public class MaxAreaofIsland {
+ public int maxAreaOfIsland(int[][] grid) {
+ List list =new ArrayList<>();
+ for( int i =0 ;imax){
+ max=i;
+ }
+ }
+ return max;
+ }
+
+ public static void main(String[] args) {
+// int[][] a =new int[][]{{1,1,0,0,0},{1,1,0,0,0},{0,0,0,1,1},{0,0,0,1,1}};
+ int[][] a =new int[][]{{0},{0}};
+ new MaxAreaofIsland().maxAreaOfIsland(a);
+ }
+}
diff --git a/src/main/java/Leetcode/MinimumAbsoluteDifferenceinBST.java b/src/main/java/Leetcode/MinimumAbsoluteDifferenceinBST.java
new file mode 100644
index 0000000..c540a1b
--- /dev/null
+++ b/src/main/java/Leetcode/MinimumAbsoluteDifferenceinBST.java
@@ -0,0 +1,130 @@
+package Leetcode;
+
+/**
+ * @author szh
+ * @create 2018-07-25 22:41
+ **/
+public class MinimumAbsoluteDifferenceinBST {
+
+ TreeNode nodeval=null;
+ int min=Integer.MAX_VALUE;
+
+ ///////
+ public int getMinimumDifferenceTwo(TreeNode root) {
+ if(root != null)
+ compareTreeNode(root);
+ return min;
+ }
+ public void compareTreeNode(TreeNode node){
+
+ if(node == null){
+ return;
+ }
+ compareTreeNode(node.left);
+ if(nodeval != null){
+ min =Math.min(node.val - nodeval.val ,min);
+ }
+ nodeval =node;
+ compareTreeNode(node.right);
+ }
+
+
+
+
+
+ /////
+ public int getMinimumDifference(TreeNode root) {
+ if(root != null){
+ return compareTree(Integer.MAX_VALUE,root);
+ }
+ return 0;
+ }
+ public int compareTree(int min ,TreeNode node){
+
+ if(node.left != null){
+
+ TreeNode leftNode =node.left;
+ min=Math.min(min,compareTree(min,leftNode));
+ int leftVal =Math.abs(node.val- node.left.val);
+ if(min > leftVal){
+ min= leftVal;
+ }
+// return compareTree(min,leftNode);
+ }
+ if(node.right != null){
+ int rightVal =Math.abs(node.val- node.right.val);
+ if(min > rightVal){
+ min= rightVal;
+ }
+ TreeNode rightNode =node.right;
+ min =Math.min(min,compareTree(min,rightNode));
+ }
+ return min;
+ }
+
+// public int compareTreeV2(int min ,TreeNode root,TreeNode node){
+//
+// int value = Math.abs(root.val - node.val);
+// if(root.left != null){
+//// int leftVal =Math.abs(node.val- node.left.val);
+//// if(min > leftVal){
+//// min= leftVal;
+//// }
+// TreeNode leftNode =node.left;
+//// return compareTree(min,leftNode);
+// }
+// if(node.right != null){
+// int rightVal =Math.abs(node.val- node.right.val);
+// if(min > rightVal){
+// min= rightVal;
+// }
+// TreeNode rightNode =node.right;
+//// return compareTree(min,rightNode);
+// }
+// return min;
+// }
+ int minDiff = Integer.MAX_VALUE;
+ TreeNode prev;
+
+ public int getMinimum(TreeNode root) {
+ inorder(root);
+ return minDiff;
+ }
+
+ public void inorder(TreeNode root) {
+ if (root == null) return;
+ inorder(root.left);
+ if (prev != null) minDiff = Math.min(minDiff, root.val - prev.val);
+ prev = root;
+ inorder(root.right);
+ }
+
+
+ public static void main(String[] args) {
+ TreeNode t =new TreeNode(1);
+ TreeNode t1 =new TreeNode(5);
+ TreeNode t2 =new TreeNode(3);
+ t1.left=t2;
+ t.right=t1;
+
+// TreeNode t =new TreeNode(236);
+// TreeNode t1 =new TreeNode(104);
+// TreeNode t2 =new TreeNode(227);
+// TreeNode t3 =new TreeNode(701);
+// TreeNode t4 =new TreeNode(911);
+// t1.right=t2;
+// t3.right=t4;
+// t.left=t1;
+// t.right=t3;
+// System.out.println(new MinimumAbsoluteDifferenceinBST().getMinimumDifference(t));
+// System.out.println(new MinimumAbsoluteDifferenceinBST().getMinimum(t));
+ System.out.println(new MinimumAbsoluteDifferenceinBST().getMinimumDifferenceTwo(t));
+ }
+
+}
+ class TreeNode {
+ int val;
+ TreeNode left;
+ TreeNode right;
+ TreeNode(int x) { val = x; }
+ }
diff --git a/src/main/java/Leetcode/MinimumDistanceBetweenBSTNodes.java b/src/main/java/Leetcode/MinimumDistanceBetweenBSTNodes.java
new file mode 100644
index 0000000..0d15798
--- /dev/null
+++ b/src/main/java/Leetcode/MinimumDistanceBetweenBSTNodes.java
@@ -0,0 +1,58 @@
+package Leetcode;
+
+/**
+ * @author szh
+ * @create 2018-08-24 22:20
+ **/
+public class MinimumDistanceBetweenBSTNodes {
+// public static int difference =1000;
+// public static TreeNode node1;
+// public int minDiffInBST(TreeNode root) {
+// if(root != null){
+// compareNode(root);
+// }
+// return difference;
+// }
+// public void compareNode(TreeNode node){
+// if(node == null){
+// return ;
+// }
+// compareNode(node.left);
+// if(node1 != null){
+// difference= Math.min(Math.abs(node.val - node1.val), difference);
+// }
+// node1 = node;
+// compareNode(node.right);
+// }
+public static int difference1 =1000;
+ public static TreeNode node1;
+ public int minDiffInBST(TreeNode root) {
+ if(root != null){
+ compareNode(root);
+ }
+ return difference1;
+ }
+ public void compareNode(TreeNode node){
+ if(node == null){
+ return ;
+ }
+ compareNode(node.left);
+ if(node1 != null){
+ difference1= Math.min(difference1 , Math.abs(node.val - node1.val));
+ }
+ node1 = node;
+ compareNode(node.right);
+ }
+ public static void main(String[] args) {
+ TreeNode t =new TreeNode(27);
+ TreeNode t1 =new TreeNode(34);
+ TreeNode t2 =new TreeNode(58);
+ TreeNode t3 =new TreeNode(50);
+ TreeNode t4 =new TreeNode(44);
+ t3.left = t4;
+ t2.left=t3;
+ t1.right=t2;
+ t.right=t1;
+ System.out.println(new MinimumDistanceBetweenBSTNodes().minDiffInBST(t));
+ }
+}
diff --git a/src/main/java/Leetcode/MissingNumber.java b/src/main/java/Leetcode/MissingNumber.java
new file mode 100644
index 0000000..099e7cc
--- /dev/null
+++ b/src/main/java/Leetcode/MissingNumber.java
@@ -0,0 +1,29 @@
+package Leetcode;
+
+import java.util.Arrays;
+
+/**
+ * @author szh
+ * @create 2018-09-14 23:44
+ **/
+public class MissingNumber {
+ public int missingNumber(int[] nums) {
+ Arrays.sort(nums);
+ if(nums == null || nums.length == 0){
+ return 0;
+ }
+ int result =0;
+ int i =0;
+ for( ; i< nums.length ; i++){
+ result += (i ^ nums[i]);
+ }
+ result = result ^ i;
+ return result;
+ }
+
+ public static void main(String[] args) {
+ System.out.println(0 ^ 1);
+ System.out.println(1 ^ 2);
+ System.out.println((0 ^ 1));
+ }
+}
diff --git a/src/main/java/Leetcode/MostCommonWord.java b/src/main/java/Leetcode/MostCommonWord.java
new file mode 100644
index 0000000..93d6e64
--- /dev/null
+++ b/src/main/java/Leetcode/MostCommonWord.java
@@ -0,0 +1,51 @@
+package Leetcode;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author szh
+ * @create 2018-08-18 23:31
+ **/
+public class MostCommonWord {
+ public static void main(String[] args) {
+ new MostCommonWord().mostCommonWord("Bob hit a ball, the hit BALL flew far after it was hit.", new String[]{"hit"});
+ }
+
+ public String mostCommonWord(String paragraph, String[] banned) {
+ String[] words = paragraph.split(" ");
+ Set set = new HashSet<>();
+ for (String s : banned) {
+ set.add(s);
+ }
+ Map map = new HashMap<>();
+ for (String word : words) {
+ StringBuffer sb = new StringBuffer();
+ char[] cArray = word.toCharArray();
+ for (char c : cArray) {
+ if (Character.isLetter(c)) {
+ sb.append(c);
+ }
+ }
+ // word= word.replace(",","");
+ // word= word.replace(".","");
+ word = sb.toString();
+ word = word.toLowerCase();
+ map.put(word, map.get(word) == null ? 1 : map.get(word) + 1);
+ }
+ for (String s : set) {
+ map.remove(s);
+ }
+ String max = null;
+ int maxNum = 0;
+ for (Map.Entry temp : map.entrySet()) {
+ if ((int) temp.getValue() > maxNum) {
+ maxNum = (int) temp.getValue();
+ max = (String) temp.getKey();
+ }
+ }
+ return max;
+ }
+}
diff --git a/src/main/java/Leetcode/NumberofBoomerangs.java b/src/main/java/Leetcode/NumberofBoomerangs.java
new file mode 100644
index 0000000..fbb4c51
--- /dev/null
+++ b/src/main/java/Leetcode/NumberofBoomerangs.java
@@ -0,0 +1,72 @@
+package Leetcode;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author szh
+ * @create 2018-09-03 23:54
+ **/
+public class NumberofBoomerangs {
+ public int numberOfBoomerangs(int[][] points) {
+ Map map =new HashMap<>();
+ int res=0;
+ for(int i =0 ;i< points.length ;i++){
+ for(int j=0 ;j< points.length ;j++){
+ if(i == j){
+ continue;
+ }
+ int ditance =getDistance(points[i],points[j]);
+ map.put(ditance,map.getOrDefault(ditance,0)+1);
+ }
+ for(int val :map.values()){
+ res+=(val*2);
+ }
+ map.clear();
+ }
+ return res;
+
+ }
+ public int getDistance(int[] a ,int[] b){
+ // int dx =(a[0]-b[0]) < 0 ? b[0]- a[0] :a[0]-b[0];
+ int dx =a[0]-b[0];
+ // int dy=(a[1]-b[1]) < 0 ? b[1]- a[1] :a[1]-b[1];
+ int dy=a[1]-b[1] ;
+ return dx* dx + dy *dy;
+ }
+
+ public static void main(String[] args) {
+// int[][] a =new int[][]{new int[]{0,0},new int[]{0,0},new int[]{0,0}};
+ int[][] a =new int[][]{{0,0},{1,0},{2,0}};
+ new NumberofBoomerangs().numberOfBoomerangs(a);
+ new NumberofBoomerangs().numberOfBoomerangs2(a);
+ }
+ public int numberOfBoomerangs2(int[][] points) {
+ int res = 0;
+
+ Map map = new HashMap<>();
+ for(int i=0; i map =new HashMap<>();
+ new PositionsofLargeGroups().largeGroupPositions(s);
+; }
+ public List> largeGroupPositions(String S) {
+ char[] c =S.toCharArray();
+ List> result =new ArrayList<>();
+ int start =0;
+ for(int i =1 ;i=3){
+ List temp =new ArrayList<>();
+ temp.add(start);
+ temp.add(i-1);
+ result.add(temp);
+ }
+ start =i;
+ }
+ }
+ return result;
+ }
+}
diff --git a/src/main/java/Leetcode/RotateString.java b/src/main/java/Leetcode/RotateString.java
new file mode 100644
index 0000000..bd5ea95
--- /dev/null
+++ b/src/main/java/Leetcode/RotateString.java
@@ -0,0 +1,63 @@
+package Leetcode;
+
+import java.math.BigInteger;
+
+/**
+ * @author szh
+ * @create 2018-08-16 22:48
+ **/
+public class RotateString {
+ public boolean rotateString(String A, String B) {
+ String C = A +A ;
+ for(int i =0 ;i< C.length() ;i++){
+ int index =i;
+ int j=0;
+ for(;j val){
+ return compareAndSelect(root.left,val);
+ }else{
+ return compareAndSelect(root.right,val);
+ }
+ }
+ public TreeNode compareAndSelect(TreeNode node , int val){
+ if(node == null){
+ return null;
+ }
+ if(node.val == val){
+ return node;
+ }
+ if(node.val >val){
+ return compareAndSelect(node.left,val);
+ }else{
+ return compareAndSelect(node.right,val);
+ }
+ }
+
+ class TreeNode {
+ int val;
+ TreeNode left;
+ TreeNode right;
+
+ TreeNode(int x) {
+ val = x;
+ }
+ }
+}
diff --git a/src/main/java/Leetcode/StudentAttendanceRecord.java b/src/main/java/Leetcode/StudentAttendanceRecord.java
new file mode 100644
index 0000000..033edb7
--- /dev/null
+++ b/src/main/java/Leetcode/StudentAttendanceRecord.java
@@ -0,0 +1,67 @@
+package Leetcode;
+
+/**
+ * @author szh
+ * @create 2018-09-15 21:53
+ **/
+public class StudentAttendanceRecord {
+ public static void main(String[] args) {
+// char c1 = 'A';
+// char c2 = 'P';
+// char c3 = 'C';
+// System.out.println(c1 == 1);
+// System.out.println(c1 ^ c2);
+// int[] i = new int[10];
+// System.out.println('C' ^ 1);
+// System.out.println('C' ^ 2);
+// System.out.println('C' ^ 3);
+// System.out.println('C' ^ 4);
+// System.out.println('C' | 1);
+// System.out.println('C' | 2);
+// System.out.println('C' | 3);
+// System.out.println('C' | 4);
+// System.out.println('C' ^ 5);
+// System.out.println('C' ^ 6);
+// System.out.println('C' ^ 7);
+// System.out.println('C' ^ 8);
+// System.out.println('C' ^ 9);
+// System.out.println('C' ^ 10);
+// System.out.println('C' ^ 11);
+// System.out.println('C' ^ 12);
+// System.out.println('C' ^ 13);
+// int count =0;
+// System.out.println(upLouti(0, 20));
+// System.out.println(count);
+// int[] a = new int[21];
+// a[0] = 1;
+// a[1] = 1;
+// a[2] = 1;
+//
+// for (int i = 3; i <= 20; i++) {
+// a[i] = a[i-1] + a[i-3];
+// System.out.println(i + " " + a[i]);
+// }
+ System.out.println(puCiZhuan(0, 20));
+ }
+
+
+ private static int upLouti(int step ,int end ){
+ if(step == end || step == end -1 ){
+ return 1;
+ }
+ return upLouti(step+1,end) + upLouti(step+2,end);
+ }
+
+ private static int puCiZhuan(int step ,int end){
+ if(step >= end){
+ return 0;
+ }
+ if(step == end -1){
+ return 1;
+ }
+ if(step == end -3){
+ return 2;
+ }
+ return puCiZhuan(step+1,end) + puCiZhuan(step + 3 ,end);
+ }
+}
diff --git a/src/main/java/Leetcode/bitand2bitCharac.java b/src/main/java/Leetcode/bitand2bitCharac.java
new file mode 100644
index 0000000..3a65bcc
--- /dev/null
+++ b/src/main/java/Leetcode/bitand2bitCharac.java
@@ -0,0 +1,40 @@
+package Leetcode;
+
+/**
+ * @author szh
+ * @create 2018-08-17 22:50
+ **/
+public class bitand2bitCharac {
+ public boolean isOneBitCharacter(int[] bits) {
+ int len =bits.length;
+ if(bits == null || bits.length == 0){
+ return false;
+ }
+ if(len == 1 && bits[len-1] == 0){
+ return true;
+ }
+ if(len == 2 && bits[0] == 0){
+ return true;
+ }else if(bits[0] == 1){
+ return false;
+ }
+ if(len >=3){
+ if(len % 2 == 0){
+ if(bits[len-2] == 1){
+ return false;
+ }else{
+ return true;
+ }
+ }else{
+ if(bits[len-3] == 1){
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ public static void main(String[] args) {
+ new bitand2bitCharac().isOneBitCharacter(new int[]{1,0,0});
+ }
+}
diff --git a/src/main/java/Loop/Hello.asm b/src/main/java/Loop/Hello.asm
new file mode 100644
index 0000000..73feaf0
Binary files /dev/null and b/src/main/java/Loop/Hello.asm differ
diff --git a/src/main/java/Loop/LoopTest.asm b/src/main/java/Loop/LoopTest.asm
new file mode 100644
index 0000000..73feaf0
Binary files /dev/null and b/src/main/java/Loop/LoopTest.asm differ
diff --git a/src/main/java/Loop/LoopTest.class b/src/main/java/Loop/LoopTest.class
new file mode 100644
index 0000000..9c85b02
Binary files /dev/null and b/src/main/java/Loop/LoopTest.class differ
diff --git a/src/main/java/Loop/LoopTest.java b/src/main/java/Loop/LoopTest.java
new file mode 100644
index 0000000..46d5f94
--- /dev/null
+++ b/src/main/java/Loop/LoopTest.java
@@ -0,0 +1,28 @@
+package Loop;
+
+/**
+ * @author szh
+ * @create 2018-05-21 20:31
+ **/
+public class LoopTest {
+ private static void maxOut(){
+ int[] a =new int[100];
+ for(int i = 0; i<200 ;i++){
+ for(int j=0;j<10;j++){
+ a[i]=a[j]+1;
+ }
+ }
+ }
+ private static void minOut(){
+ int[] a =new int[100];
+ for(int i = 0; i<10 ;i++){
+ for(int j=0;j<200;j++){
+ a[i]=a[j]+1;
+ }
+ }
+ }
+ public static void main(String[] args){
+ maxOut();
+ minOut();
+ }
+}
diff --git a/src/main/java/NettyInAction/ch2/echo/EchoClient.java b/src/main/java/NettyInAction/ch2/echo/EchoClient.java
index bce4639..4481285 100644
--- a/src/main/java/NettyInAction/ch2/echo/EchoClient.java
+++ b/src/main/java/NettyInAction/ch2/echo/EchoClient.java
@@ -3,10 +3,7 @@
import io.netty.bootstrap.Bootstrap;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
-import io.netty.channel.Channel;
-import io.netty.channel.ChannelFuture;
-import io.netty.channel.ChannelInitializer;
-import io.netty.channel.EventLoopGroup;
+import io.netty.channel.*;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.SocketChannel;
import io.netty.channel.socket.nio.NioSocketChannel;
@@ -40,20 +37,29 @@ protected void initChannel(SocketChannel socketChannel) throws Exception {
}
});
ChannelFuture f= b.connect().sync();
+ f.addListener(new ChannelFutureListener() {
+ @Override
+ public void operationComplete(ChannelFuture channelFuture) throws Exception {
+ if(f.isSuccess()){
+ System.out.println("有客户端链接");
+ }
+ }
+ });
Channel channel =f.channel();
Scanner scanner =new Scanner(System.in);
// ByteBuf byteBuf=null;
while (true){
String Message =scanner.nextLine();
if(Message.length() != 0){
+ if(Message.equals("exit")){
+ break;
+ }
// byteBuf.writeBytes(Message.getBytes());
System.out.println(Message);
// f.channel().writeAndFlush(Unpooled.copiedBuffer(Message,CharsetUtil.UTF_8));
// f.channel().flush();
System.out.println(f.channel().isActive());
e.list.get(0).writeAndFlush(Unpooled.copiedBuffer(Message,CharsetUtil.UTF_8));
- }if(Message =="exit"){
- break;
}
}
f.channel().closeFuture().sync();
diff --git a/src/main/java/NettyInAction/ch2/echo/EchoClientHandle.java b/src/main/java/NettyInAction/ch2/echo/EchoClientHandle.java
index 8eaf1f1..70f94e3 100644
--- a/src/main/java/NettyInAction/ch2/echo/EchoClientHandle.java
+++ b/src/main/java/NettyInAction/ch2/echo/EchoClientHandle.java
@@ -2,6 +2,7 @@
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
+import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.util.CharsetUtil;
@@ -12,12 +13,16 @@
/**
* Created by szh on 2017/5/22.
*/
+@ChannelHandler.Sharable
public class EchoClientHandle extends SimpleChannelInboundHandler{
public String Message;
public static List list =new ArrayList<>();
- @Override
+// @Override
+// protected void channelRead0(ChannelHandlerContext channelHandlerContext, ByteBuf byteBuf) throws Exception {
+// System.out.println("客端接受到的数据是" + byteBuf.toString(CharsetUtil.UTF_8));
+// }
protected void channelRead0(ChannelHandlerContext channelHandlerContext, ByteBuf byteBuf) throws Exception {
- System.out.println("客端接受到的数据是" + byteBuf.toString(CharsetUtil.UTF_8));
+ System.out.println("客端接受到的数据是channelRead0" + byteBuf.toString(CharsetUtil.UTF_8));
}
@Override
@@ -34,6 +39,12 @@ public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws E
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
ByteBuf buf = (ByteBuf) msg;
- System.out.println("客端接受到的数据是" + buf.toString(CharsetUtil.UTF_8));
+ System.out.println("客端接受到的数据是channelRead" + buf.toString(CharsetUtil.UTF_8));
+ }
+
+ @Override
+ protected void messageReceived(ChannelHandlerContext channelHandlerContext, ByteBuf byteBuf) throws Exception {
+ System.out.println("客端接受到的数据是messageReceived" + byteBuf.toString(CharsetUtil.UTF_8));
+
}
}
diff --git a/src/main/java/OperationTest/IntAndChar.java b/src/main/java/OperationTest/IntAndChar.java
new file mode 100644
index 0000000..cafc139
--- /dev/null
+++ b/src/main/java/OperationTest/IntAndChar.java
@@ -0,0 +1,14 @@
+package OperationTest;
+
+/**
+ * @author szh
+ * @create 2018-06-08 23:30
+ **/
+public class IntAndChar {
+ public static void main(String[] args) {
+ char c='C';
+ System.out.println(90 - c);
+ String s ="qwert";
+ System.out.println(s.substring(0, 2));
+ }
+}
diff --git a/src/main/java/PECS/PECSTest.java b/src/main/java/PECS/PECSTest.java
new file mode 100644
index 0000000..e0cb0cd
--- /dev/null
+++ b/src/main/java/PECS/PECSTest.java
@@ -0,0 +1,25 @@
+package PECS;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author szh
+ * @create 2018-06-01 11:17
+ **/
+public class PECSTest {
+ private void t(){
+ List extends A> list =new ArrayList<>();
+ B b = new B();
+ A a =new A();
+ }
+}
+
+class A{
+
+}
+class B extends A{
+ public void b(){
+ System.out.println("b");
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/SFVideoDowland/CssVideo/CssVideo.java b/src/main/java/SFVideoDowland/CssVideo/CssVideo.java
new file mode 100644
index 0000000..ea115a9
--- /dev/null
+++ b/src/main/java/SFVideoDowland/CssVideo/CssVideo.java
@@ -0,0 +1,109 @@
+package SFVideoDowland.CssVideo;
+
+import org.apache.http.Header;
+import org.apache.http.HttpEntity;
+import org.apache.http.client.ClientProtocolException;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * @author szh
+ * @create 2018-05-24 19:21
+ **/
+public class CssVideo {
+ protected static void main(String[] args) {
+ start();
+ }
+ private static void start(){
+ CloseableHttpClient httpClient = HttpClients.createDefault();
+ int i=18;
+// while (i<290){
+
+
+ try {
+ HttpGet httpGet=null;
+ if(i<10){
+ httpGet = new HttpGet("https://media.video.segmentfault.com/eab963VTCl4LPZ4y8phbYaCjKqg=/lgOR6NwUEuGWs5MuNnHEW67PeDzu/00000"+String.valueOf(i)+".ts");
+ }else if(i<100){
+ httpGet = new HttpGet("https://media.video.segmentfault.com/eab963VTCl4LPZ4y8phbYaCjKqg=/lgOR6NwUEuGWs5MuNnHEW67PeDzu/0000"+String.valueOf(i)+".ts");
+ }else{
+ httpGet = new HttpGet("https://media.video.segmentfault.com/eab963VTCl4LPZ4y8phbYaCjKqg=/lgOR6NwUEuGWs5MuNnHEW67PeDzu/000"+String.valueOf(i)+".ts");
+ }
+
+// httpGet.setHeader("accept-ranges", "bytes6");
+// httpGet.setHeader("access-control-allow-origin", "*");
+// httpGet.setHeader("access-control-expose-headers", "X-Log, X-Reqid");
+// httpGet.setHeader("access-control-max-age", "2592000");
+// httpGet.setHeader("age", "0");
+// httpGet.setHeader("cache-control", "max-age=2592000");
+// httpGet.setHeader("content-disposition", "inline; filename=\"000001.ts\"; filename*=utf-8' '000001.ts"); //TODO
+// httpGet.setHeader("content-length", "558172");
+// httpGet.setHeader("content-transfer-encoding", "tbinary");
+// httpGet.setHeader("date", "video/mp2t");
+// httpGet.setHeader("content-type", "Thu, 24 May 2018 11:05:04 GMT");
+// httpGet.setHeader("etag", "FunorSPF5uS7h3Tn4lxYCLZu0zGv");
+// httpGet.setHeader("expires", "Sat, 23 Jun 2018 11:05:04 GMT");
+// httpGet.setHeader("expires", "Sat, 23 Jun 2018 11:05:04 GMT");
+// httpGet.setHeader("last-modified", "Tue, 02 Jan 2018 06:50:51 GMT");
+// httpGet.setHeader("server", "marco/2.2");
+// httpGet.setHeader("status", "200");
+// httpGet.setHeader("via", "T.11.-, V.mix-gd-can-005, T.69.N, M.cun-hb-wuh-069");
+// httpGet.setHeader("x-log", "mc.g/404;rs12_12.sel/not found;rs11_12.sel;rwro.get:1;RS.dbs:1;RS:1;mc.s;mc.g;IO:33");
+// httpGet.setHeader("x-m-log", "QNM:xs446;QNM3:23");
+// httpGet.setHeader("x-m-reqid", "1RkAACcY3UsWOygV");
+// httpGet.setHeader("x-qiniu-zone", "1");
+// httpGet.setHeader("x-qnm-cache", "Hit");
+// httpGet.setHeader("x-reqid", "q1QAAK99xfjqEiYV");
+// httpGet.setHeader("x-request-id", "36e9b5c2525194a6147b248e0cf2be26");
+// httpGet.setHeader("x-slice-complete-length", "558172");
+// httpGet.setHeader("x-slice-etag", "T.11.-, V.mix-gd-can-005, T.69.N, M.cun-hb-wuh-069");
+// httpGet.setHeader("x-slice-size", "FunorSPF5uS7h3Tn4lxYCLZu0zGv");
+// httpGet.setHeader("x-source", "C/200");
+// httpGet.setHeader("x-svr", "IO");
+ httpGet.setHeader("Origin", "https://segmentfault.com");
+ httpGet.setHeader("Referer", "https://segmentfault.com/l/1500000012666812/play");
+ httpGet.setHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36");
+ CloseableHttpResponse response = httpClient.execute(httpGet);
+ try {
+ HttpEntity httpEntity = response.getEntity();
+ if (httpClient != null) {
+ InputStream inputStream = httpEntity.getContent();
+ File file = new File("D:\\JavaBasis\\cookies\\0000"+String.valueOf(i)+".ts");
+ FileOutputStream fileout = new FileOutputStream(file);
+ byte[] bytes = new byte[1024];
+ int len;
+ while ((len = inputStream.read(bytes)) != -1) {
+// String s = new String(bytes, 0, len);
+ fileout.write(bytes, 0, len);
+ fileout.flush();
+ }
+ fileout.close();
+ inputStream.close();
+ }
+
+// int len =0;
+// while ((len=inputStream.read()) !=-1){
+//
+//
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ } catch (ClientProtocolException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+// i++;
+// }
+ }
+ public void te(){
+
+ }
+}
diff --git a/src/main/java/SFVideoDowland/CssVideo/ProtectTest.java b/src/main/java/SFVideoDowland/CssVideo/ProtectTest.java
new file mode 100644
index 0000000..4466387
--- /dev/null
+++ b/src/main/java/SFVideoDowland/CssVideo/ProtectTest.java
@@ -0,0 +1,15 @@
+package SFVideoDowland.CssVideo;
+
+/**
+ * @author szh
+ * @create 2018-05-24 23:31
+ **/
+public class ProtectTest {
+ protected int i;
+ protected void protectMethod(){
+
+ }
+ public void publicMethod(){
+
+ }
+}
diff --git a/src/main/java/SetAndMap/TreeSetAndTreeMap/PojoTest.java b/src/main/java/SetAndMap/TreeSetAndTreeMap/PojoTest.java
new file mode 100644
index 0000000..dcd53f3
--- /dev/null
+++ b/src/main/java/SetAndMap/TreeSetAndTreeMap/PojoTest.java
@@ -0,0 +1,35 @@
+package SetAndMap.TreeSetAndTreeMap;
+
+
+/**
+ * @author szh
+ * @create 2018-05-24 17:03
+ **/
+public class PojoTest {
+ private int id;
+ private String name;
+
+ public PojoTest() {
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public PojoTest(int id, String name) {
+ this.id = id;
+ this.name = name;
+ }
+}
diff --git a/src/main/java/SetAndMap/TreeSetAndTreeMap/ProT.java b/src/main/java/SetAndMap/TreeSetAndTreeMap/ProT.java
new file mode 100644
index 0000000..6786a0f
--- /dev/null
+++ b/src/main/java/SetAndMap/TreeSetAndTreeMap/ProT.java
@@ -0,0 +1,14 @@
+package SetAndMap.TreeSetAndTreeMap;
+
+import SFVideoDowland.CssVideo.ProtectTest;
+
+/**
+ * @author szh
+ * @create 2018-05-24 23:32
+ **/
+public class ProT extends ProtectTest{
+ public static void main(String[] args) {
+ ProtectTest protectTest =new ProtectTest();
+ protectTest.publicMethod();
+ }
+}
diff --git a/src/main/java/SetAndMap/TreeSetAndTreeMap/TestTreeSet.java b/src/main/java/SetAndMap/TreeSetAndTreeMap/TestTreeSet.java
new file mode 100644
index 0000000..d59f57a
--- /dev/null
+++ b/src/main/java/SetAndMap/TreeSetAndTreeMap/TestTreeSet.java
@@ -0,0 +1,130 @@
+package SetAndMap.TreeSetAndTreeMap;
+
+import com.sun.xml.internal.messaging.saaj.packaging.mime.util.LineInputStream;
+import org.junit.Test;
+import sun.reflect.generics.tree.Tree;
+
+import java.util.*;
+
+/**
+ * TreeSet的测试类
+ *
+ * @author szh
+ * @create 2018-05-24 15:53
+ **/
+public class TestTreeSet{
+
+
+ private static void construct(){
+ Comparator comparator =new Comparator() {
+ @Override
+ public int compare(String o1, String o2) {
+ if(o1.toCharArray()[0] >o2.toCharArray()[0]){
+ return -1;
+ }else if(o1.toCharArray()[0] == o2.toCharArray()[0]){
+ return 0;
+ }else{
+ return 1;
+ }
+ }
+ };
+ TreeSet treeSet =new TreeSet<>(comparator);
+ List list =new ArrayList<>();
+ list.add("a");
+ list.add("d");
+ list.add("b");
+ treeSet.addAll(list);
+ Iterator iterator =treeSet.iterator();
+ while (iterator.hasNext()){
+ System.out.println(iterator.next());
+ }
+ Comparator comparator1 = (Comparator) treeSet.comparator();
+ TreeSet treeSet1 =new TreeSet<>(comparator1);
+ treeSet1.add("c");
+ treeSet1.add("g");
+ treeSet1.add("a");
+ Iterator iterator1 =treeSet1.iterator();
+ while (iterator1.hasNext()){
+ System.out.println(iterator1.next());
+ }
+// TreeSet treeSet1 =treeSet.comparator();
+// Iterator iterator2=treeSet1.iterator();
+// while (iterator2.hasNext()){
+// System.out.println(iterator.next());
+// }
+ }
+
+ private static void compareWithCpmparator(){
+ Stack