原创 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 wa
原创 redis 編譯/調試
下載 redis 源碼 安裝make, gcc, aptitude(如果報gcc版本不適合的錯)。
原创 netty nio處理
netty的nio處理NioWorerk類。 NioWorker類實現了 Runnable 接口。 register方法用於 open 一個 Selector。 void register(NioSocketChannel
原创 String matching in an array
class Solution { public List<String> stringMatching(String[] words) { if (words == null || words.length
原创 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) {
原创 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. M
原创 Maximum Length of Repeated Subarray.
dp. class Solution { public int findLength(int[] A, int[] B) { if (A == null || A.length == 0 || B == n
原创 Sort Integers by the Number of 1 Bits
快排,注意比較的方法,因爲 bitCount 相同時也要排序。 class Solution { public int[] sortByBits(int[] arr) { if (arr == null |
原创 Map Sum Pairs
things like prefix should use Trie. I draw a picture to display this solution. rootabc...sub_a1sub_b1sub_c1sub_a2su
原创 [leetcode][easy]Two Sum
class Solution { public int[] twoSum(int[] nums, int target) { int[] result = new int[2]; if (n
原创 Number of days
import java.time.LocalDate; import java.time.temporal.ChronoUnit; class Solution { public int daysBetweenDates
原创 Maximum Score After Splitting a String
可以先統計所有 1 的數量。 因爲肯定要分隔的,所以 i < s.length() - 1 。 /** Runtime: 2 ms, faster than 100.00% of Java online submissions f
原创 [LeetCode][easy]Reformat The String
如果字母的數量和數字的數量之差爲 0 或 1,則可以 reformat。注意如果之差爲 1,那麼多的那種字符應該先寫。 /** Runtime: 2 ms, faster than 98.95% of Java online su
原创 [LeetCode][easy]Longest Commong Prefix
分治法,l, mid, r 分爲 (l, mid) 和 (mid+1, r) class Solution { public String longestCommonPrefix(String[] strs) {
原创 [LeetCode][easy]Create Target Array
讀題讀了好幾遍纔看明白,是往指定下標進行插入操作,而不是更新。 /* Runtime: 3 ms, faster than 14.63% of Java online submissions for Create Target A