- 博客(430)
- 资源 (5)
- 收藏
- 关注
原创 tomcat source code in eclipse
downloadtomcat’s source code can be downloaded in the tomcat.apache.org websit;antant’s official websit.procedurethere’s no need to configure something like ANT_HOME .etc;execute ant command and ant ide-eclipse command, then import existing project
2021-11-27 02:04:31
301
原创 tomcat/redis/dubbo/netty
tomcat need to learn WAR format, xml parser .etc, which I do note like, quit;redis, written with C language, I want to learn it, and rewrite with Java;dubbo, must learn;netty, must learn, draw UML graph, and write one copy.
2020-05-24 21:51:27
184
原创 Network Delay Time
宽度搜索 bfs。此题所求为时间而非距离,故最终结果为到某个节点的最大值。此题的输入里,会有如下情况。环;多路时间比单路时间短;多路时间与单路时间相同。class Solution { public int networkDelayTime(int[][] times, int N, int K) { if (times == null) { ...
2020-05-01 12:07:01
214
原创 Remove Comments
this problem needs to be dealed character by character each line, as there’re multi-cases.I just copy one solution here.Steps:Iterate each line from the input document.Inside the line, iterate ea...
2020-05-01 10:15:49
260
原创 Map Sum Pairs
things like prefix should use Trie. I draw a picture to display this solution./**Runtime: 12 ms, faster than 56.55% of Java online submissions for Map Sum Pairs.Memory Usage: 40 MB, less than 14....
2020-04-28 16:11:36
158
原创 Maximum Length of Repeated Subarray.
dp.class Solution { public int findLength(int[] A, int[] B) { if (A == null || A.length == 0 || B == null || B.length == 0) { return 0; } int[][] dp = new i...
2020-04-28 15:39:13
122
原创 Check If N and Its Double Exist
i need to be even when checking set.contains(i / 2).class Solution { public boolean checkIfExist(int[] arr) { if (arr == null || arr.length == 0) { return false; } ...
2020-04-28 15:24:16
270
原创 Can Place Flowers
可以种植的情况(下标 i):i == 0 && arr[i+1] == o && arr[i] = 0;i == arr.length - 1 && arr[i] == 0 && arr[i-1] == 0;arr[i] == 0 && arr[i-1] == 0 && arr[i+1] == ...
2020-04-27 20:49:51
181
原创 N-ary Tree Preorder Traversal
/**Runtime: 1 ms, faster than 69.62% of Java online submissions for N-ary Tree Preorder Traversal.Memory Usage: 40.1 MB, less than 100.00% of Java online submissions for N-ary Tree Preorder Travers...
2020-04-27 20:22:26
175
原创 Number of Steps toreduce a number to zero
/**Runtime: 45 ms, faster than 7.47% of Java online submissions for Number of Steps to Reduce a Number to Zero.Memory Usage: 40.2 MB, less than 100.00% of Java online submissions for Number of Step...
2020-04-27 15:22:42
226
原创 Sort Integers by the Number of 1 Bits
k快排,注意比较的方法,因为 bitCount 相同时也要排序。class Solution { public int[] sortByBits(int[] arr) { if (arr == null || arr.length == 0) { return new int[0]; } quickSort(arr,...
2020-04-27 14:32:13
166
原创 String matching in an array
class Solution { public List<String> stringMatching(String[] words) { if (words == null || words.length == 0) { return new ArrayList<>(); } HashSet&...
2020-04-27 13:59:28
145
原创 Maximum Score After Splitting a String
可以先统计所有 1 的数量。因为肯定要分隔的,所以 i < s.length() - 1 。/**Runtime: 2 ms, faster than 100.00% of Java online submissions for Maximum Score After Splitting a String.Memory Usage: 38.8 MB, less than 100.0...
2020-04-26 16:55:09
326
原创 Number of days
import java.time.LocalDate;import java.time.temporal.ChronoUnit;class Solution { public int daysBetweenDates(String date1, String date2) { if (date1 == null || date1.length() == 0 || da...
2020-04-26 16:08:31
192
原创 [LeetCode][easy]Create Target Array
读题读了好几遍才看明白,是往指定下标进行插入操作,而不是更新。/*Runtime: 3 ms, faster than 14.63% of Java online submissions for Create Target Array in the Given Order.Memory Usage: 39.7 MB, less than 100.00% of Java online sub...
2020-04-26 15:57:23
272
原创 [LeetCode][easy]Rank Transform of an Array
排序加 map 可以做。/**Runtime: 24 ms, faster than 79.61% of Java online submissions for Rank Transform of an Array.Memory Usage: 56.1 MB, less than 100.00% of Java online submissions for Rank Transform o...
2020-04-25 19:22:46
213
原创 [LeetCode][easy]Reformat The String
如果字母的数量和数字的数量之差为 0 或 1,则可以 reformat。注意如果之差为 1,那么多的那种字符应该先写。/**Runtime: 2 ms, faster than 98.95% of Java online submissions for Reformat The String.Memory Usage: 39.5 MB, less than 100.00% of Java ...
2020-04-25 18:36:32
233
原创 [LeetCode][easy]Longest Commong Prefix
分治法,l, mid, r 分为 (l, mid) 和 (mid+1, r)class Solution { public String longestCommonPrefix(String[] strs) { String result = ""; if (strs == null || strs.length == 0) { r...
2020-04-25 18:08:44
125
原创 [LeetCode][easy]Roman to Integer
从低位到高位,如果上一位代表的数值比该位小,则减,否则加。class Solution { private static HashMap<Character, Integer> map = new HashMap<>(); static { map.put('I', 1); map.put('V', 5)...
2020-04-25 17:39:07
104
原创 [leetcode][easy]Two Sum
class Solution { public int[] twoSum(int[] nums, int target) { int[] result = new int[2]; if (nums == null || nums.length == 0) { return result; } HashM...
2020-04-25 17:21:28
120
原创 安装Ubuntu18
新高了个本子,自带的win10,我时了一次,开机后30分钟沙也不做,磁盘一直在80~100之间,这是defender在扫盘好像。于是就庄了个Ubuntu18,没装19。apt-get install 很香,vim按小 o 换下一行,按大 O 换上一行。shell也搞起来了,redis, mongodb本机就跑起来了,只是 apt-get 安装的软件都默认开机启动,也罢,不想折腾,作web开发需...
2020-04-21 15:59:07
411
原创 工作记录
我自然是会使用markdown的。我工作前博客写的挺勤快的,工作后我以为会保持下去,然并卵。工作使人烦躁,不能让一个上了10+小时班的人下班后再心平气和的写博客。我为什么回来写博客其实我挺烦csdn的,在我注册的时候,只需要个邮箱就可以了,现在要绑定手机号,还要关注工总号,这是不能忍的。期间我试了博客园、itEye等,这几个博客站点页面干净,只是编辑器好难用,并且没有我以前的博文积累。不能不...
2020-04-21 15:48:55
155
原创 Java Foundation serial ( 一 )
Everything is ObjectJava是强类型、静态、面向对象的语言。强类型:每个类型的值、操作都被限制在相应的范围内;静态:每个变量、表达式在编译器就有一个类型。面向对象思想封装继承多态...
2020-01-14 20:46:56
124
原创 back
I'm backi know how to write Markdown, so …我一直想再找个博客,但是都不满意,今天看到我以前在这个博客上闲扯淡,心想不错啊,于是决定回来了。
2018-12-15 15:55:20
168
原创 本地Git仓库关联Github项目
登录Github后新建Repository,记下类似类似git@github.com:XXX/XXX.git的地址;如果是Windows下,选择Git Bash,git config –global user.email “jethai@126.com”;先检查SSH keys是否已经存在,ls -al ~/.ssh,如果没有id_dsa.pub、id_ecdsa.pub、id_ed2551...
2018-03-03 19:15:34
452
原创 -------------分割线-------
时间飞逝,已然找到了工作,是家物流企业,在物流里也算家大公司了,他也有研发部,称为“**云”,工资还行。但与同学的工作相比就什么都不算了,毕竟我是转专业的,还行吧。我需要恶补基础,主要是408的内容,我买了《深入理解操作系统》和《TCP/IP协议族》俩本书,只有这两本肯定是不够的,但是先把这两本看完再说吧。还要补的基础有Java和算法,我有《Java编程思想》和《算法导论》两本书,很靠谱的俩本书。我
2017-10-26 15:15:28
708
原创 拼多多笔试题
无序数组,包含负数、0、正数,求三个数使乘积最大 考虑到俩个负数相乘可以为正数,min1 * min2 * max1 或者 max1 * max2 * max3,但是int * int * int,就需要用long来保存结果,否则就是只过了22.22%的用例。俩个字符串代表的大数相乘,不能用Java自带的函数。 http://blog.youkuaiyun.com/fightforyourdream/a
2017-08-01 22:29:45
3339
原创 暂存
分布式架构:(了解原理就行,如果真的有实践经验更好) CAP原理和BASE理论。 Nosql与KV存储(redis,hbase,mongodb,memcached等) 服务化理论(包括服务发现、治理等,zookeeper、etcd、springcloud微服务、) 负载均衡(原理、cdn、一致性hash) RPC框架(包括整体的一些框架理论,通信的netty,序列化协议thrift,pro
2017-07-30 11:19:07
428
原创 华为提前批机试题目
都说程序员是最爱分享的一类人 :) 第一道: 水仙花数: 我记忆里做的第一道编程题有没有。。。 输出100到999里的数,这个数要求每位的数字的三次方之和等于该数字。另外最后还要输出这些水仙花数的总和。 解题过程:按题目一步步写喽。第二道: 字符 . 代表1,字符 - 代表 0。输入类型“–.#。#-.-”的字符串,字符#是分隔符,可能会有连续的多个#。把形如“–.”的无符号二进制转
2017-07-06 21:38:51
2567
1
原创 二叉树的inorder实现:递归、栈、Morris遍历
不包含null值检查等robust代码。递归:inorderTreeWalk(TreeNode root) { if(root != null) { inorderTreeWalk(root.left); System.out.println(root.val); inorderTreeWalk(root.right); }}栈:in
2017-05-04 14:21:15
1433
原创 Java:关于负数的向上转型
int的负数n向上转型为long时,应该写成-(long)n,而不是(long)-n。 举例:int n = Integer.MIN_VALUE;//-2147483648System.out.println(-(long)n);//2147483648System.out.println((long)-n);//-2147483648
2017-04-27 14:32:54
518
原创 bfs和dfs:poj2386和leetcode130
poj2386#include <iostream>using namespace std;const int MAX_NM = 105;char ch[MAX_NM][MAX_NM];int m, n;void dfs(int x, int y) { ch[x][y] = '.'; for(int i=-1; i<=1; i++) { for(int j=-1;
2017-04-22 14:54:40
475
原创 为什么InnoDB表要建议用自增列做主键而MyISAM不需要
我们先了解下InnoDB引擎表的一些关键特征:InnoDB引擎表是基于B+树的索引组织表(IOT); 每个表都需要有一个聚集索引(clustered index);所有的行记录都存储在B+树的叶子节点(leaf pages of the tree); 基于聚集索引的增、删、改、查的效率相对是最高的;如果我们定义了主键(PRIMARY KEY),那么InnoDB会选择其作为聚集索引;如果没有显
2017-04-11 20:06:54
3707
原创 kmp算法及解释
KMP算法属于单模式字符串匹配算法。我通过看书和看网上的博客,做笔记于此。 先做一个形象的解释(http://kb.cnblogs.com/page/176818/): 这种算法不太容易理解,网上有很多解释,但读起来都很费劲。直到读到Jake Boxer的文章,我才真正理解这种算法。下面,我用自己的语言,试图写一篇比较好懂的KMP算法解释。 1. 首先,字符串”BBC A
2017-04-10 12:04:44
503
转载 JAVA中方法和变量在继承中的覆盖和隐藏
转自:http://www.cnblogs.com/linth/p/3641175.html我们知道,在JAVA中,子类可以继承父类,如果子类声明的方法与父类有重名的情况怎么办,大伙儿都知道要是重写,但是实际上这又分为两种情况,就是方法和变量在继承时的覆盖和隐藏问题,这些概念性的东西看似无聊,但是在面试或者是SCJP认证题中围绕这些是会经常碰到的,所以这里来讨论下首先我们来看几个概念类变量:又叫静态
2017-04-09 20:51:04
551
原创 Chapter 5 : 索引和算法
Chapter 5 : 索引和算法InnoDB存储引擎索引概述 B+树里的“B”是指平衡(balance),而不是二叉(binary)。由于B+索引的高扇出性能,在数据库中,B+树的高度一般都在2~3蹭,也就是对于查找某一键值的行记录,最多只需要2到3次IO。 聚集索引 辅助索引(非聚集索引)
2017-04-08 16:42:53
490
文本挖掘(英文版)
2016-04-03
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人