Java practice - http://www.javapractices.com/home/HomeAction.do
Openfire REST API version - https://www.igniterealtime.org/projects/openfire/plugins/1.3.7/restAPI/readme.html
TCP Retrans - https://accedian.com/enterprises/blog/network-packet-loss-retransmissions-and-duplicate-acknowledgements/
2024年1月29日星期一
2019年6月7日星期五
关于LDAP协议
LDAP 在网络七层结构中属于哪一层?
LDAP - 轻量级目录访问协议。属于会话层(Session Layer),在建立和管理session的时候使用。
怎样找到某个 domain 的 ldap server?
LDAP - 轻量级目录访问协议。属于会话层(Session Layer),在建立和管理session的时候使用。
怎样找到某个 domain 的 ldap server?
2019年1月28日星期一
2019年1月27日星期日
2019年1月26日星期六
2019年1月24日星期四
2019年1月23日星期三
[LeetCode] 338. Counting Bits
要累晕啦,做一道简单的,本来想用一个循环来数一个整型的二进制有多少个1,但是超时了。只能用个投机取巧的方法了……
查了一下Integer.bitCount()的实现,肯定是记不住的啊ㄟ(▔▽▔)ㄏ
查了一下Integer.bitCount()的实现,肯定是记不住的啊ㄟ(▔▽▔)ㄏ
2019年1月22日星期二
[LeetCode] 279. Perfect Squares
啦啦啦,四平方和定理是啥,我不懂啊~( ̄▽ ̄~)(~ ̄▽ ̄)~
初始化还把值搞错了,竟然溢出啦~
报名参加比赛,然后不做题,排名竟然会倒退!!!
初始化还把值搞错了,竟然溢出啦~
报名参加比赛,然后不做题,排名竟然会倒退!!!
2019年1月21日星期一
[LeetCode] 31. Next Permutation
这道题卡了好久,终于做出来了,都要绕晕了ㄟ(▔▽▔)ㄏ
比较无聊的一点是,如果没有看到这个算法,是不太可能做出来的 Next lexicographical permutation algorithm
2019年1月20日星期日
[LeetCode] 134. Gas Station
O(n^2) 的复杂度好像有些高,不知道有没有更快的方法解决 \(▔▽▔)/
更新:找到了很巧妙的方法。确实一次遍历就可以解决。~( ̄▽ ̄~)(~ ̄▽ ̄)~
https://blog.csdn.net/JackZhang_123/article/details/78008439
https://blog.csdn.net/JackZhang_123/article/details/78008439
2019年1月9日星期三
2019年1月8日星期二
2019年1月7日星期一
[LeetCode] 190. Reverse Bits
https://leetcode.com/problems/reverse-bits/
最简单的想法是位运算一位一位的挪,用for循环搞定(要注意优先级和结合性的问题):
然后看到了别人一个不用循环的解法:
https://leetcode.com/problems/reverse-bits/discuss/54741/O(1)-bit-operation-C++-solution-(8ms)
很巧妙的利用了交换的时候这种特性:abcdefgh -> efghabcd -> ghefcdab -> hgfedcba 好困啊,只好用简单题交差啦 ~( ̄▽ ̄~)(~ ̄▽ ̄)~
最简单的想法是位运算一位一位的挪,用for循环搞定(要注意优先级和结合性的问题):
然后看到了别人一个不用循环的解法:
https://leetcode.com/problems/reverse-bits/discuss/54741/O(1)-bit-operation-C++-solution-(8ms)
很巧妙的利用了交换的时候这种特性:abcdefgh -> efghabcd -> ghefcdab -> hgfedcba 好困啊,只好用简单题交差啦 ~( ̄▽ ̄~)(~ ̄▽ ̄)~
2018年12月30日星期日
[LeetCode] 5. Longest Palindromic Substring
https://leetcode.com/problems/longest-palindromic-substring/
明天再想想其他解法 \(▔▽▔)/
解法一:使用了在水中的鱼的博客看到的第一种思路(http://fisherlei.blogspot.com/2012/12/leetcode-longest-palindromic-substring.html),对于任意一个index,分别向前、向后查找可能的palindrome。因为palindrome有“aba”和“abba”两种形式,所以还需要照顾到当s[index]==s[index + 1]这种情况。时间复杂度 O(n^2)。代码如下:
明天再想想其他解法 \(▔▽▔)/
2018年4月2日星期一
Bash 的基本语法规则
1. 函数传参
#!/bin/bash
test_function() {
echo $1 $2
}
test_function "hello" "world"
Result:
~$ ./example.sh
hello world
2. 分割字符串
#!/bin/bash
LINE="test_name,test_address,test_phone_number"
name=$(echo $LINE | cut -d ',' -f 1)
address=$(echo $LINE | cut -d ',' -f 2)
phone_number=$(echo $LINE | cut -d ',' -f 3)
echo $name
echo $address
echo $phone_number
Result:
~$ ./example.sh
test_name
test_address
test_phone_number
3. 读取文件
#!/bin/bash
i=0
SPACE=" "
while read line
do
echo $i $SPACE $line
i=$((i+1))
done < test.txt
Result:
~$ cat test.txt
hahaha
haha
ha
~$ ./example.sh
0 hahaha
1 haha
2 ha
4. 正则表达式匹配
#!/bin/bash
LINE="This is a test string. Let's see if the UUID will be matched: ea77b80d-d17f-476a-b55f-916423d02dcc. Hahaha!"
uuid=$(echo $LINE | grep -E -o '[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}')
echo $uuid
Result:
~$ ./example.sh
ea77b80d-d17f-476a-b55f-916423d02dcc
2018年4月1日星期日
Hazelcast 学习笔记
(1) Install maven - https://stackoverflow.com/a/ 17481557
~$ ls /Library/Java/ JavaVirtualMachines/jdk1.8.0_ 161.jdk/Contents/Home
export JAVA_HOME=/Library/Java/ JavaVirtualMachines/jdk1.8.0_ 161.jdk/Contents/Home
(2) build a maven package - https://www.mkyong.com/maven/ how-to-build-project-with- maven/
(3) Exception in thread "main" com.hazelcast.license. exception. InvalidLicenseException: License Key not configured!
(4) Replication vs. partitioning
(5) Most common use case: being a cache on top of a database
(6) Hazelcast has two modes: embedded mode and client-server mode
2017年11月29日星期三
About memory leak
(WIP)
* jvisualvm
** ssh -X
* jmap
* example of memory leak: https://dzone.com/articles/memory-leak-andjava-code
* jvisualvm
** ssh -X
* jmap
* example of memory leak: https://dzone.com/articles/memory-leak-andjava-code
2017年9月27日星期三
Trie Implementation
public class Trie {
static final int ALPHABET_SIZE = 26;
static class TrieNode {
TrieNode[] children = new TrieNode[ALPHABET_SIZE];
boolean isEndOfWord;
TrieNode() {
isEndOfWord = false;
for (int i = 0; i < ALPHABET_SIZE; i++) {
children[i] = null;
}
}
}
static TrieNode root;
// if not parent, inserts key into trie
// if the key is prefix of trie node, just mark leaf node
static void insert(String key) {
int level;
int length = key.length();
int index;
TrieNode pCrawl = root;
for (level = 0; level < length; level++) {
index = key.charAt(level) - 'a';
if (pCrawl.children[index] == null) {
pCrawl.children[index] = new TrieNode();
}
pCrawl = pCrawl.children[index];
}
// mark the last node as leaf
pCrawl.isEndOfWord = true;
}
// Returns true if key presnts in trie, else false
static boolean search(String key) {
int level;
int length = key.length();
int index;
TrieNode pCrawl = root;
for (level = 0; level < length; level++) {
index = key.charAt(level) - 'a';
if (pCrawl.children[index] == null) {
return false;
}
pCrawl = pCrawl.children[index];
}
return pCrawl != null && pCrawl.isEndOfWord;
}
}
2016年10月8日星期六
[LeetCode] #200 Number of Islands
public class Solution {
public int numIslands(char[][] grid) {
int result = 0;
if (grid == null || grid.length == 0 || grid[0].length == 0) {
return result;
}
for (int i = 0; i < grid.length; i++) {
for (int j = 0; j < grid[0].length; j++) {
if (grid[i][j] == '1') {
result++;
dfs(grid, i, j);
}
}
}
return result;
}
private void dfs(char[][] grid, int i, int j) {
if (grid[i][j] != '1') {
return;
}
grid[i][j] = '2';
if (i - 1 >= 0) {
dfs(grid, i - 1, j);
}
if (j - 1 >= 0) {
dfs(grid, i, j - 1);
}
if (i + 1 < grid.length) {
dfs(grid, i + 1, j);
}
if (j + 1 < grid[0].length) {
dfs(grid, i, j + 1);
}
}
}
订阅:
博文 (Atom)