/images/avatar.png

Check SWAP

Check SWAP used by differnt PID 1 for i in $(cd /proc;ls | grep "^[0-9]" | awk '$0>100'); do awk '/Swap:/{a=a+$2}END{print '"$i"',a/1024"M"}' /proc/$i/smaps;done| sort -k2nr | head Get the information about the PID 1 ps aux | grep ${pid}

lc1570. Dot Product of Two Sparse Vectors

给定两个稀疏向量,计算它们的点积(数量积)。 实现类 SparseVector: SparseVector(nums) 以向量 nums 初始化对象。 dotProduct(vec) 计算此向量与 vec 的点积。 稀疏向量 是指绝大多数分量为 0 的向量。你需要 高效 地存储这个向量,并计算两个稀疏向量的点积。 进阶:当其中只有一个向量是稀疏向量时,你该如何解决此问题? 示例 1: 输入:nums1 = [1,0,0,2,3], nums2 = [0,3,0,4,0] 输出:8 解释:v1 = SparseVector(nums1) , v2 = SparseVector(nums2) v1.dotProduct(v2) = 10 + 03 + 00 + 24 + 3*0 = 8 示例 2: 输入:nums1 = [0,1,0,0,0], nums2 = [0,0,0,0,2] 输出:0 解释:v1 = SparseVector(nums1) , v2 = SparseVector(nums2) v1.dotProduct(v2) = 00 + 10 + 00 + 00 + 0*2 = 0

lc50. Pow(x, n)

Implement pow(x, n), which calculates x raised to the power n (i.e., xn). Example 1: 1 2 Input: x = 2.00000, n = 10 Output: 1024.00000 Example 2: 1 2 Input: x = 2.10000, n = 3 Output: 9.26100 Example 3: 1 2 3 Input: x = 2.00000, n = -2 Output: 0.25000 Explanation: 2-2 = 1/22 = 1/4 = 0.25 Constraints: -100.0 < x < 100.0 -231 <= n <= 231-1 -104 <= xn <= 104 思路