自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(18)
  • 资源 (1)
  • 收藏
  • 关注

原创 手写分布式锁

最近写了一个分布式锁https://github.com/majinliang123/messtin-lock功能如下:例子public class Example1 { public static void main(String[] args) throws InterruptedException { LockClient client = Loc...

2018-12-22 12:03:04 378

原创 手写rpc框架

最近写了一个rpc的简单的框架。https://github.com/majinliang123/messtin-rpc

2018-12-22 12:00:02 170

转载 LeetCode: 894. All Possible Full Binary Trees

题目:894. All Possible Full Binary Trees(https://leetcode.com/problems/all-possible-full-binary-trees/description/).这个问题是典型的递归问题,首先读题之后可知有性质“完全二叉树结点个数必定为奇数”。所以问题变简单了点,如果输入N为偶数,直接输出空List即可。对于一个有n个结点的...

2018-10-18 18:09:00 174

原创 LeetCode: 23. Merge k Sorted Lists

题目: 23. Merge k Sorted Lists(https://leetcode.com/problems/merge-k-sorted-lists/description/)class Solution { public ListNode mergeKLists(ListNode[] lists) { ListNode result = null, tai...

2018-10-16 14:04:21 88

原创 LeetCode: 767 Reorganize String

题目: 767 Reorganize String (https://leetcode.com/problems/reorganize-string/)每次取当前出现频率最高的两个字母拼接在字符串上。直到PriorityQueue中元素的数量只有一个或者没有。如果只有一个且他还有大于1的频率,就说明这个字符创无法Reorganize。class Solution { public...

2018-10-16 13:38:16 131

翻译 LeetCode: 210. Course Schedule II

题目: 210. Course Schedule II(https://leetcode.com/problems/course-schedule-ii/description/)public class Solution { public int[] findOrder(int numCourses, int[][] prerequisites) { if (numCourses ...

2018-09-25 11:28:12 254

原创 LeetCode: 436. Find Right Interval

题目: 436. Find Right Interval(https://leetcode.com/problems/find-right-interval/description/)public class Solution { public int[] findRightInterval(Interval[] intervals) { NavigableMap<I...

2018-09-21 18:15:09 97

原创 LeetCode: 392. Is Subsequence

题目: LeetCode: 392. Is Subsequence(https://leetcode.com/problems/is-subsequence/description/)class Solution { public boolean isSubsequence(String s, String t) { int currentLoc = 0; byte[] byte...

2018-09-21 17:40:34 121

原创 LeetCode: 792. Number of Matching Subsequences

题目: LeetCode: 792. Number of Matching Subsequences(https://leetcode.com/problems/number-of-matching-subsequences/description/) class Solution { public int numMatchingSubseq(String S, String[]...

2018-09-21 16:09:54 206

原创 LeetCode: 592. Fraction Addition and Subtraction

题目:592. Fraction Addition and Subtraction(https://leetcode.com/problems/fraction-addition-and-subtraction/description/)解法:首先对字符串进行拆分,组成一个个分数,然后分数通分相加,最后约分。import java.util.ArrayList;import java....

2018-09-13 12:03:30 192

原创 ThreadPoolExecutor源码解析

基本概念线程池是一种多线程处理形式,处理过程中将任务添加到队列,然后在创建线程后自动启动这些任务。继承关系ThreadPoolExecutor继承了AbstractExecutorService,AbstractExecutorService继承了ExecutorService,ExecutorService继承了Executor。public interface Executo...

2018-09-13 10:26:27 95

原创 LeetCode: 890. Find and Replace Pattern

题目:890. Find and Replace Pattern(https://leetcode.com/problems/find-and-replace-pattern/description/)解法:将元素的出现的位置放入数组中,当元素第一次出现时,他在数组中的值是默认值0,当相同的再次元素出现时,它在数组中的值应该相同,否则说明不匹配。class Solution { p...

2018-09-10 16:59:02 134

原创 LeetCode: 74. Search a 2D Matrix

题目:74. Search a 2D Matrix(https://leetcode.com/problems/search-a-2d-matrix/description/)解法:将二维数组看成一维数组,元素的坐标可以计算出来。此解法使用二分查找。public class Solution { public boolean searchMatrix(int[][] matrix...

2018-09-10 16:14:00 93

原创 ReentrantLock源码解析

1. 基本概念ReentrantLock是一种排他锁,拥有synchronized的功能但是又比synchronized强大。ReentrantLock可以以公平或者非公平的方式去获取锁,默认采用非公平的方式去获取锁。本文主要讲解默认方式(非公平的去获取锁)2. 继承关系ReentrantLock实现了Lock和Serializable,所以ReentrantLock需要实现Lock的...

2018-09-09 19:48:08 119

原创 LeetCode: 341. Flatten Nested List Iterator

题目:341. Flatten Nested List Iterator(https://leetcode.com/problems/flatten-nested-list-iterator/description/)解法:使用DFS先将所有的Integer存到一个List中,然后使用这个List的Iterator。public class NestedIterator implem...

2018-09-06 10:44:31 135

原创 LeetCode: 733. Flood Fill

题目: 733. Flood Fill(https://leetcode.com/problems/flood-fill/description/)解法1:将符合条件的坐标放在一个队列里面,每次取一个(取完就在队列中移除),然后检查该坐标上下左右四个点中符合要求的坐标放进队列里,直到队列为空为止。class Solution { public int[][] floodFill...

2018-09-04 21:44:26 153

原创 Thread local不会发生out of memory

网上有很多文章说ThreadLocal会发生out of memory.但是当我创建大量ThreadLocal对象的时候,并没有发生异常,而且Element对象被正常的垃圾回收了。通过jvisualvm可以看到,确实GC发生了如果你们有异常发生,请留言。// -XX:+PrintGCDetails -Xms100m -Xmx100mpublic class Test {   ...

2018-09-03 11:32:57 140

原创 java 8 ConcurrentHashMap源码解析

简介java(版本:1.8.0_161) 中ConcurrentHashMap主要在多线程中使用,dev不需要自己保证数据同步。用法基本上和HashMap相似。本文主要讲解源码中的put方法是怎么工作的。让我们带着问题去看源码。 问题1. ConcurrentHashMap是如何保证多个线程同时调用put方法时而不出现错误的2.ConcurrentHashMap是如何进行扩容的...

2018-06-07 22:21:58 172 1

Counterparty credit risk and credit value adjustment

Counterparty credit risk and credit value adjustment

2018-01-22

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除