Timers and time management in the Linux kernel. Part 6
这篇文章 Timers and time management in the Linux kernel. Part 6. 是出自 linux-insides
这篇文章 Timers and time management in the Linux kernel. Part 6. 是出自 linux-insides
题目: Given a binary tree, return the inorder traversal of its nodes’ values. Example: Input: 1 2 3 4 5 6 [1,null,2,3] 1 \ 2 / 3 Output: 1 [1,3,2] Follow up: Recursive solution is trivial, could you do it iteratively? 解题: 遍历顺序“根-左-右” 实现: 使用栈实现 从根节点开始,先将根节点压入栈,保存结果值,然后移动到左节点, 保证“根-左”顺序, 为空后出栈,取其右节点入栈中。这样就保证了访问顺序为“根-左-右”。 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 33 /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */ class Solution { public: vector<int> preorderTraversal(TreeNode* root) { vector<int> res; stack<TreeNode*> ss; TreeNode *p = root; while (!ss.empty()||p){ if (p!=NULL){ ss.push(p); res.push_back(p->val); p = p->left; } else{ p = ss.top(); ss.pop(); p=p->right; } } return res; } }; 实现: 递归实现 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 class Solution { public: vector<int> preorderTraversal(TreeNode* root) { vector<int> res; preorder(root, res); return res; } void preorder(TreeNode *root, vector<int> &res){ if (!root) return; res.push_back(root->val); preorder(root->left, res); preorder(root->right, res); } }; 参考: [LeetCode] 144. Binary Tree Preorder Traversal 二叉树的先序遍历 ...
对于正常使用rm无法删除的文件可以通过查找inode进行删除 1 2 ls -i find -inum xxx -delete or 1 2 ls -i find -inum xxx -exec rm -i {} \; 直接删除 1 2 3 4 5 6 7 8 9 [root@centosgpt vm]# ls -i 2278688 > 13592459 memdump2.c~ 13592454 memzero 7506486 test.c~ 2275894 118902.mem 2275882 memdump2.py 13592461 memzero.c 9733651 translate ... [root@centosgpt vm]# find -inum 2278688 -delete [root@centosgpt vm]# ls 118902.mem idle.py~ memdump3.c memory_layout processwrite.c test.c~ vsyscall.c 18 memdump memdump4 memory_layout.c processwrite.c~ translate 交互式 1 2 3 4 5 6 7 8 9 [root@centosgpt vm]# ls -i 7506464 > 13592459 memdump2.c~ 13592454 memzero 7506486 test.c~ 2275894 118902.mem 2275882 memdump2.py 13592461 memzero.c 9733651 translate [root@centosgpt vm]# find -inum 7506464 -exec rm -i {} \; rm: remove regular empty file ‘./>’? y [root@centosgpt vm]# ls 118902.mem idle.py~ memdump3.c memory_layout processwrite.c test.c~ vsyscall.c 18 memdump memdump4 memory_layout.c processwrite.c~ translate
处理器在运行程序时,需要存储器来存放程序和程序使用的数据, 现代操作系统提供了存储器的抽象:虚拟存储器, 使得应用程序来说不用过多的考虑物理存储使用,简化了内存管理
工作需要汇总整理相关excel数据信息,并按照规定格式进行反馈,用python写了一个脚本处理了一下。 样例中表格内容也进行了调整。 环境: windows10 python3.7 + openpyxl 目标: 以data1数据为准,通过查找data2补全相关信息, 将数据填入要求的result文件中。 表格格式: 表格1 data1.xlsx 姓名 张三 李四 表格2 data2.xlsx 序号 姓 名 性别 身份证号 联系电话 01 张三 男 130012345678901234 13911111111 02 李四 男 123012345678901234 13922222222 03 王五 男 123012345678901234 13933333333 表格3 result.xlsx 序号 所属部门 厂商 姓名 身份证号 联系电话 备注 代码: 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 33 34 35 36 37 38 39 40 41 42 43 44 from openpyxl import load_workbook from openpyxl import Workbook import pandas as pd wb_in = load_workbook( filename = '.\\test\\data1.xlsx') ws_in = wb_in.active ## 名字列表开始结束行号 start_index = 2 end_index = 4 wb_info = load_workbook( filename = '.\\test\\data2.xlsx') ws_info = wb_info.active wb_out = load_workbook( filename = '.\\test\\result.xlsx') ws_out = wb_out.active out_index = 2 ## 找到要统计人员姓名 for x in range(start_index,end_index): name = ws_in.cell(row=x,column=1) print(name.value) ## 查找要统计人员附件信息并更新到统计表格中 find_flag = 0 for row in ws_info.iter_rows("B"): for col in row: #print(col.value) if (str(col.value).strip() == str(name.value).strip()) and (find_flag == 0): ## 第四列 身份证 第五列 联系电话 idno = ws_info.cell(row=col.row,column=4) phoneno = ws_info.cell(row=col.row, column=5) ## 更新到统计文件 ws_out['A'+ str(out_index)].value = str(out_index-1) ws_out['B'+ str(out_index)].value = 'XX部' ws_out['C'+ str(out_index)].value = 'XXX' ws_out['D'+ str(out_index)].value = name.value ws_out['E'+ str(out_index)].value = idno.value ws_out['F'+ str(out_index)].value = phoneno.value out_index = out_index + 1 find_flag = 1 break if find_flag == 0: print(name.value) wb_out.save( filename = '.\\test\\result.xlsx') 运行结果 序号 所属部门 厂商 姓名 身份证号 联系电话 备注 1 XX部 XXX 张三 130012345678901234 13911111111 2 XX部 XXX 李四 130012345678901234 13922222222 参考 Openpyxl Doc Using openpyxl to find rows that contain cell with specific value (Python 3.6)
这篇文章 Timers and time management in the Linux kernel. Part 5. 是出自 linux-insides
题目: There are N rooms and you start in room 0. Each room has a distinct number in 0, 1, 2, ..., N-1, and each room may have some keys to access the next room. Formally, each room i has a list of keys rooms[i], and each key rooms[i][j] is an integer in [0, 1, ..., N-1] where N = rooms.length. A key rooms[i][j] = v opens the room with number v. ...
内存管理发展阶段 内存(RAM)是计算机一种重要资源, 随着应用越来越复杂,不管存储器有多大,程序都可以把他填满,这就迫使人们不断寻找解决方案去管理它. 内存管理经历的几个阶段; 无存储抽象阶段 (No Memory abstraction) 地址空间 (Address Spaces) 虚拟内存 (Virtual Memory) 无存储抽象阶段: 直接使用物理地址, 简单和划分了用户和操作系统,(驱动程序)使用的内存. 早期的MSDOS采用这种管理方案。 通过每个进程基址寄存器和界限寄存器实现动态重定位,映射到不通的物理内存。通过交换技术和空闲内存管理, 处理内存超载 构建虚拟地址空间,通过MMU(内存管理单元)完成虚拟内存与物理内存的映射。 分页 分页就是出现虚拟内存这个阶段.虚拟地址按照固定大小划分成若干个页面Page, 物理内存中对应为页框 Page Frame (物理内存最小数据单位), 当程序试图访问内存时,MMU根据虚拟地址映射为物理地址. 页面大小 不同处理器体系结构页面大小 体系结构 最小页面 支持大页面 32-bit x86 4 KiB 4 MiB, 2 MiB x86-64 4 KiB 2 MiB, 1 GiB IA-64 (Itanium) 4 KiB 8 KiB, 64 KiB, 256 KiB, 1 MiB, 4 MiB, 16 MiB, 256 MiB Power ISA 4 KiB 64 KiB, 16 MiB, 16 GiB SPARC v8 with SPARC Reference MMU 4 KiB 256 KiB, 16 MiB ARMv7 4 KiB 64 KiB, 1 MiB , 16 MiB UltraSPARC Architecture 2007 8 KiB 64 KiB, 512 KiB , 4 MiB, 32 MiB, 256 MiB, 2 GiB, 16 GiB 页面大小考虑因素(wiki) 页面大小通常有处理器体系结构决定, 目前常用页面大小4KB。选择最佳页面大小要考虑一下几个因素: ...
这篇文章 Huge TLB Pages是出Linux Kernel文档
cenos7X86_64 + openssh - windows10 - putty