CSAPP 7 连接
CSAPP 7 连接,Linking
连接是将程序的不同部分(指令和数据)组合成一个二进制文件,该文件可以被读入内存并被CPU执行。连接可以发生在编译时,即程序从源代码转换成机器码的过程中(Static Linking);也可以发生在装载阶段,即程序被读入内存的阶段(Dynamic Linking);甚至可以在运行时,即程序已经被读入内存且已经开始执行的时候。
连接器操作的对象被称为目标文件:Relocatable object file
, Executable object file
, Shared object file
。
目标文件的格式是约定俗成的,最常见的是ELF
, Executable and Linkable Format。
在C语言中,
static
关键字通常用来隐藏变量或者函数。
874. Walking Robot Simulation
874. Walking Robot Simulation
这是一个简单,但是设计的很好的面试题。并没有困难的算法,考验的是一个软件工程师能都写出清晰、简洁代码的能力,以及一些细节问题。
问题
1 | A robot on an infinite XY-plane starts at point (0, 0) and faces north. The robot can receive one of three possible types of commands: |
CSAPP 6 存储的层次
1192 Critical Connections in a Network
1192. Critical Connections in a Network
1192. Critical Connections in a Network
问题
There are n servers numbered from 0 to n-1 connected by undirected server-to-server connections forming a network where connections[i] = [a, b] represents a connection between servers a and b. Any server can reach any other server directly or indirectly through the network.A critical connection is a connection that, if removed, will make some server unable to reach some other server.
Return all critical connections in the network in any order.
Tree层遍历
Tree层遍历
- 102 Binary Tree Level Order Traversal
- 107 Binary Tree Level Order Traversal II
- 1302. Deepest Leaves Sum
- 637 Average of Levels in Binary Tree
102 Binary Tree Level Order Traversal
题目
Given the root of a binary tree, return the level order traversal of its nodes’ values. (i.e., from left to right, level by level).
一个简单的算术 LL1 Parser
回溯 DFS
回溯,DFS
- 46. Permutations
- 47. Permutations II
- 1466. Reorder Routes to Make All Paths Lead to the City Zero
- 679. 24 Game
- 282. Expression Add Operators
46. Permutations
问题
Given an array nums of distinct integers, return all the possible permutations. You can return the answer in any order.
Heap 使用
Heap(堆)的使用
- 1046. Last Stone Weight
- 703. Kth Largest Element in a Stream
- 1792. Maximum Average Pass Ratio
- 621. Task Schedule
1046. Last Stone Weight
思路
此题比较直接,直接采用heap来维护最重的数值在头部,需要注意的是 Python 的 heap 都是 min heap,所以需要取负数来实现此题。