![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
面试算法
文章平均质量分 77
文艺小木头
多多积累
展开
-
链表相关(反转链表、合并两个有序链表、两个链表的第一个公共结点、链表入环结点、倒数第k个结点)
package Suanfa;import java.util.*;class ListNode { int val; ListNode next; ListNode(int x) { this.val = x; next = null; } int getVal() { return this.val; }}public class 链表 { pub...原创 2018-08-30 21:41:40 · 109 阅读 · 0 评论 -
生产者——消费者 blockingqueue实现
package Interview;import java.util.concurrent.BlockingQueue;import java.util.concurrent.LinkedBlockingQueue;class 生产者 implements Runnable{ BlockingQueue<String>queue; public 生产者(Blocking...原创 2018-09-10 14:33:09 · 170 阅读 · 0 评论 -
并发demo
package Thread;class ThreadMode{ public Thread getThread() { Thread thread=new Thread(new Runnable() { public void run() { for(int i = 0;i < 1024 ; i++){ System.out...转载 2018-08-30 16:02:56 · 225 阅读 · 0 评论 -
ThreadLocal_demo
package Thread;import java.util.Random;public class ThreadLocal_demo { public static class MyRunnable implements Runnable{ private ThreadLocal<Integer>threadLocal=new ThreadLocal<>...转载 2018-08-30 16:00:25 · 490 阅读 · 0 评论 -
callable+线程池
package Thread;import java.util.*;import java.util.concurrent.*;public class Callable_线程池 { public static void main(String[] args) throws InterruptedException, ExecutionException { // TODO Au...原创 2018-08-30 15:59:14 · 800 阅读 · 0 评论 -
SimpleDateFormat线程安全问题解决方案
https://blog.csdn.net/qq_22866497/article/details/69641602https://blog.csdn.net/qq_22866497/article/details/696416021.问题。 作为一个准毕业生,在平时的练习中鲜有遇见多线程的练习,所以从来没有意识到SimpleDateFormat还会有线程安全问题。前几天看了Leade...转载 2018-08-30 15:57:46 · 275 阅读 · 0 评论 -
二叉树的遍历(递归、非递归、层次、最大高度)
package Suanfa;import java.util.*;class BinaryTreeNode { int val; BinaryTreeNode left; BinaryTreeNode right; public BinaryTreeNode(int val) { this.val = val; this.left = null; this.rig...原创 2018-08-30 15:49:32 · 255 阅读 · 1 评论 -
质因数分解
package Suanfa;import java.util.ArrayList;public class 质因数分解 { // 分解质因数 public static ArrayList<Integer> yinshufenjie(int number) { ArrayList<Integer> list = new ArrayList<>...原创 2018-09-01 21:15:45 · 342 阅读 · 0 评论 -
全排列
dfs的思想package Suanfa;import java.util.*;public class 全排列 { static HashSet<String> set = new HashSet<>(); public static void main(String[] args) { // TODO Auto-generated method...原创 2018-09-01 21:14:31 · 87 阅读 · 0 评论 -
java反射_demo
https://blog.csdn.net/stonesing/article/details/52358288package Interview;import java.lang.*;import java.lang.reflect.*;//https://blog.csdn.net/stonesing/article/details/52358288//一个person父类...转载 2018-09-01 21:11:52 · 323 阅读 · 0 评论 -
countdownlatch_demo和CyclicBarrier_demo
代码参考https://www.cnblogs.com/nullzx/p/5272807.htmlpackage Thread;import java.util.*;import java.util.concurrent.*;//控制一个线程等待多个线程public class CountDownLatchDemo { // a、b、c、d同时交给线程池,c、d会在a、b结束后...转载 2018-09-01 11:05:00 · 245 阅读 · 0 评论 -
排序算法(冒泡、选择、插入、希尔、归并、快排、堆排序)
package Sort;public class sort { // https://www.cnblogs.com/onepixel/articles/7674659.html public static void main(String[] args) { int[] arr = { 2, 6, 3, 5, 7, 3, 6, 8 }; HeapSort(arr); ...原创 2018-08-31 09:21:52 · 398 阅读 · 0 评论 -
二分查找(递归、非递归)和斐波那契数列
package Suanfa;public class 二分查找和斐波那契数列 { public static void main(String[] args) { // TODO Auto-generated method stub int []arr={1,2,3,6,7,8}; int index=二分查找递归(arr,9,0,arr.length); System...原创 2018-08-31 09:16:40 · 198 阅读 · 0 评论 -
重写hashcode和equals方法,以及加入treeset实现comparable接口重写compareTo方法
package Interview;import java.util.*;class People implements Comparable<People> { public String name; public int age; public People(String name,int age) { this.name=name; this.age=...原创 2018-09-11 10:48:50 · 1051 阅读 · 0 评论