LeetCode – Design Circular Queue

题目: Design your implementation of the circular queue. The circular queue is a linear data structure in which the operations are performed based on FIFO (First In First Out) principle and the last position is connected back to the first position to make a circle. It is also called “Ring Buffer”. One of the benefits of the circular queue is that we can make use of the spaces in front of the queue. In a normal queue, once the queue becomes full, we cannot insert the next element even if there is a space in front of the queue. But using the circular queue, we can use the space to store new values. ...

2019-06-14 · 4 min · 758 words · Garlic Space

shell16进制hex和10进制转换

方法: 1 bc命令 [root@centosgpt ~]# echo “ibase=16; FF” |bc 255 2. bash [root@centosgpt ~]# echo $((0xFF)) 255 3. printf [root@centosgpt ~]# printf “%d\n” 0xFF 255 4. dc [root@centosgpt ~]# dc -e ‘16i FF p’ 255 限制: 其中bc,dc 可以不受整数位数限制 如:64-bit integer limit of 2^64, 当大于64位时验证下各个脚本的处理结果 1 bc [root@centosgpt ~]# echo “ibase=16; 7FFFFFFFFFFFFFFFF” |bc 147573952589676412927 2 echo [root@centosgpt ~]# echo $((0x7FFFFFFFFFFFFFFFF)) -1 3. printf [root@centosgpt ~]# printf “%ld\n” 0x7FFFFFFFFFFFFFFFF -bash: printf: warning: 0x7FFFFFFFFFFFFFFFF: Numerical result out of range 9223372036854775807 ...

2019-06-14 · 1 min · 89 words · Garlic Space

什么是RCU:用法

RCU 在实际场景中的使用方法和最佳实践

2019-06-12 · 3 min · 435 words · Garlic Space

ELF 文件格式分析

ELF: Executable and Linkable Format

2019-06-11 · 29 min · 6085 words · Garlic Space

Vmware + Centos7 + NAT 方式连接公网

使用gdb调试时, Missing separate debuginfos, use: debuginfo-install glibc-2.17-260.el7.x86_64, 需要虚拟机联网更新。

2019-06-06 · 1 min · 122 words · Garlic Space

LeetCode – Rotate List

题目: Given a linked list, rotate the list to the right by k places, where k is non-negative. Example 1: 1 2 3 4 5 Input: 1->2->3->4->5->NULL, k = 2 Output: 4->5->1->2->3->NULL Explanation: rotate 1 steps to the right: 5->1->2->3->4->NULL rotate 2 steps to the right: 4->5->1->2->3->NULL Example 2: Input: 0->1->2->NULL, k = 4 Output: 2->0->1->NULL Explanation: rotate 1 steps to the right: 2->0->1->NULL rotate 2 steps to the right: 1->2->0->NULL rotate 3 steps to the right: 0->1->2->NULL rotate 4 steps to the right: 2->0->1->NULL ...

2019-06-03 · 2 min · 222 words · Garlic Space

Linux下实现一个系统调用

环境: cenos7

2019-06-02 · 2 min · 406 words · Garlic Space

什么是RCU

深入理解 Linux 内核 RCU(Read-Copy-Update)机制的基本原理

2019-06-02 · 2 min · 235 words · Garlic Space

ORA-01795, limit on in clause

遇到问题: 实施过程中 oracle 报错 ORA-01795, limit on in clause, 发现是SQL IN 语句中的条件从ZZ表中拼接而成。 1 2 3 4 5 6 SELECT * FROM T1 WHERE T1.VAL in ('1111', '2222', ... more than 1000 here ); 相关调整方案: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 -- 1 子查询1 SELECT VAL FROM T1 WHERE T1. VAL IN ( SELECT VAL FROM T2 ); -- 2. 子查询2 SELECT VAL FROM ( SELECT DISTINCT VAL FROM T2 ) B WHERE B.VAL=A.VAL -- 3. JOIN SELECT VAL FROM ( SELECT DISTINCT VAL FROM T2 ) B JOIN A ON B.VAL=A.VAL -- 4. EXISTS SELECT VAL FROM T1 A WHERE EXISTS ( SELECT 1 FROM T2 WHERE A.VAL=VAL ); 使用IN还是EXISTS 以下引用oracle ASK TOM 中描述: ...

2019-05-29 · 1 min · 197 words · Garlic Space

LeetCode-Copy List with Random Pointer

A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null

2019-05-28 · 3 min · 492 words · Garlic Space