原创 Graph的那些事兒

0. 導言 爲了讓代碼更加清晰,有以下一些約定: Graph的表示使用鄰接表,更詳細的說明參見 圖的表示 本文代碼中使用的圖爲 有向圖,圖中的頂點用 int 型來表示 圖的頂點數經初始化後不可變,圖的初始化有以下兩種形式 Gra

原创 LeetCode No330. Patching Array

1. 題目描述 Given a sorted positive integer array nums and an integer n, add/patch elements to the array such that any

原创 LeetCode No331. Verify Preorder Serialization of a Binary Tree

1. 題目描述 One way to serialize a binary tree is to use pre-order traversal. When we encounter a non-null node, we rec

原创 LeetCode No332. Reconstruct Itinerary

1. 題目描述 Given a list of airline tickets represented by pairs of departure and arrival airports [from, to], reconstr

原创 Web緩存工作原理

現代的商業化代理緩存相當的複雜。這些緩存構建的非常高效,可以支持HTTP和其他一些技術的各種高級特性。但除了一些微妙的細節之外,Web緩存的基本工作原理大多很簡單。對一條HTTP GET報文的基本緩存處理過程包括7個步驟: 接收

原创 PF_RING ZC流量轉發詳解

1. 準備工作 首先新建四個虛擬接口(dummy interface)進行後續的報文轉發和計數 modprobe dummy numdummies=4 ifconfig dummy0 up ifconfig dummy1 up i

原创 LeetCode No338. Counting Bits

1. 題目描述 Given a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number

原创 LeetCode No341. Flatten Nested List Iterator

1. 題目描述 Given a nested list of integers, implement an iterator to flatten it. Each element is either an integer, or

原创 Suricata+PF_RING安裝詳解

1. 前言 Suricata的安裝包可以從 github上克隆安裝,可以從Suricata官網進行下載。本文的測試以github上的版本爲例。 本文的測試平臺爲 CentOS release 6.7 (Final),不同Linu

原创 LeetCode No342. Power of Four

1. 題目描述 Given an integer (signed 32 bits), write a function to check whether it is a power of 4. Example: Given nu

原创 CAP和BASE理論

1. CAP定理 CAP理論告訴我們,一個分佈式系統不可能同時滿足一致性(C:Consistency),可用性(A:Availability)和分區容錯性(P:Partition tolerance)這三個需求,最多隻能同時滿足其

原创 LeetCode No343. Integer Break

1. 題目描述 Given a positive integer n, break it into the sum of at least two positive integers and maximize the produc

原创 LeetCode No.337. House Robber III

1. 題目描述 The thief has found himself a new place for his thievery again. There is only one entrance to this area, ca

原创 LeetCode No344. Reverse String

1. 題目描述 Write a function that takes a string as input and returns the string reversed. Example: Given s = “hello”,

原创 LeetCode No345. Reverse Vowels of a String

1. 題目描述 Write a function that takes a string as input and reverse only the vowels of a string. Example 1: Given s