OCI计算机科学面试真题

职位分类
全部
数据科学
数据分析
计算机科学
人工智能
产品经理
BQ
面试题
全部(11)
Coding(0)
System Design(4)
Algorithm(7)
Ood(0)
高频题(0)
全部(11)
Coding(0)
System Design(4)
Algorithm(7)
Ood(0)
高频题(0)
1.网络基础知识
2.Efficient task management
3.Max value in workspace
4.Min temperature in sensors
5.Leetcode 100
6.Leetcode 636
7.Leetcode 895
8.Max subarray in the array
9.Design snapshot tool
10.Design code test system
11.Find bug in code
1. 网络基础知识
1 如何判断troubleshooting 无法响应的服务器
 
 2 有哪些工具trouble shooting网络问题
 
 3 给了bash script 让walk through
 
 4 问了下如何高效稳定部署十万个服务器 并且update到指定版本
2. Efficient task management
五个关于沏茶的task,分为三个group,每个group内的任务是按顺序执行的,不同group的任务可以并行执行,但要符合生活常识(先洗,同时可以烧水,但都准备好后才可以沏茶并喝茶)。问如何以最efficient的方式实现这五个任务。(多线程,shared lock)
3. Max value in workspace
在一个二维坐标上给一些点的坐标(只会有偶数x,y坐标)作为员工办公位的坐标,绘制一条平行于x轴和一条平行于y轴的直线,把整个二维坐标划分为四个sections,使得各个工位被划分得尽量均匀(uniform distribution),并求出四个sections中工位数目的最大值。
4. Min temperature in sensors
给一个无向图连接着一些节点,每个节点代表一个temperature sensor存放着当前探测到的温度值,design一个系统来统计到所以sensor中的最低温度值。 会scale到1M个节点问如何partition。
5. Leetcode 100
1. coding 类似 Leetcode 100
 
 Given the roots of two binary trees p and q, write a function to check if they are the same or not.
 
 Two binary trees are considered the same if they are structurally identical, and the nodes have the same value.
 
 
 
 Example 1:
 
 
 Input: p = [1,2,3], q = [1,2,3]
 Output: true
 Example 2:
 
 
 Input: p = [1,2], q = [1,null,2]
 Output: false
 Example 3:
 
 
 Input: p = [1,2,1], q = [1,1,2]
 Output: false
 
 
 Constraints:
 
 The number of nodes in both trees is in the range [0, 100].
 -104 <= Node.val <= 104
 
 2. coding 类似 回文数
 
 3. SDE coding question reverse string in place
6. Leetcode 636
On a single-threaded CPU, we execute a program containing n functions. Each function has a unique ID between 0 and n-1.
 
 Function calls are stored in a call stack: when a function call starts, its ID is pushed onto the stack, and when a function call ends, its ID is popped off the stack. The function whose ID is at the top of the stack is the current function being executed. Each time a function starts or ends, we write a log with the ID, whether it started or ended, and the timestamp.
 
 You are given a list logs, where logs[i] represents the ith log message formatted as a string "{function_id}:{"start" | "end"}:{timestamp}". For example, "0:start:3" means a function call with function ID 0 started at the beginning of timestamp 3, and "1:end:2" means a function call with function ID 1 ended at the end of timestamp 2. Note that a function can be called multiple times, possibly recursively.
 
 A function's exclusive time is the sum of execution times for all function calls in the program. For example, if a function is called twice, one call executing for 2 time units and another call executing for 1 time unit, the exclusive time is 2 + 1 = 3.
 
 Return the exclusive time of each function in an array, where the value at the ith index represents the exclusive time for the function with ID i.
 
 
 
 Example 1:
 
 
 Input: n = 2, logs = ["0:start:0","1:start:2","1:end:5","0:end:6"]
 Output: [3,4]
 Explanation:
 Function 0 starts at the beginning of time 0, then it executes 2 for units of time and reaches the end of time 1.
 Function 1 starts at the beginning of time 2, executes for 4 units of time, and ends at the end of time 5.
 Function 0 resumes execution at the beginning of time 6 and executes for 1 unit of time.
 So function 0 spends 2 + 1 = 3 units of total time executing, and function 1 spends 4 units of total time executing.
 Example 2:
 
 Input: n = 1, logs = ["0:start:0","0:start:2","0:end:5","0:start:6","0:end:6","0:end:7"]
 Output: [8]
 Explanation:
 Function 0 starts at the beginning of time 0, executes for 2 units of time, and recursively calls itself.
 Function 0 (recursive call) starts at the beginning of time 2 and executes for 4 units of time.
 Function 0 (initial call) resumes execution then immediately calls itself again.
 Function 0 (2nd recursive call) starts at the beginning of time 6 and executes for 1 unit of time.
 Function 0 (initial call) resumes execution at the beginning of time 7 and executes for 1 unit of time.
 So function 0 spends 2 + 4 + 1 + 1 = 8 units of total time executing.
 Example 3:
 
 Input: n = 2, logs = ["0:start:0","0:start:2","0:end:5","1:start:6","1:end:6","0:end:7"]
 Output: [7,1]
 Explanation:
 Function 0 starts at the beginning of time 0, executes for 2 units of time, and recursively calls itself.
 Function 0 (recursive call) starts at the beginning of time 2 and executes for 4 units of time.
 Function 0 (initial call) resumes execution then immediately calls function 1.
 Function 1 starts at the beginning of time 6, executes 1 unit of time, and ends at the end of time 6.
 Function 0 resumes execution at the beginning of time 6 and executes for 2 units of time.
 So function 0 spends 2 + 4 + 1 = 7 units of total time executing, and function 1 spends 1 unit of total time executing.
 
 
 Constraints:
 
 1 <= n <= 100
 1 <= logs.length <= 500
 0 <= function_id < n
 0 <= timestamp <= 109
 No two start events will happen at the same timestamp.
 No two end events will happen at the same timestamp.
 Each function has an "end" log for each "start" log.
7. Leetcode 895
Design a stack-like data structure to push elements to the stack and pop the most frequent element from the stack.
 
 Implement the FreqStack class:
 
 FreqStack() constructs an empty frequency stack.
 void push(int val) pushes an integer val onto the top of the stack.
 int pop() removes and returns the most frequent element in the stack.
 If there is a tie for the most frequent element, the element closest to the stack's top is removed and returned.
 
 
 Example 1:
 
 Input
 ["FreqStack", "push", "push", "push", "push", "push", "push", "pop", "pop", "pop", "pop"]
 [[], [5], [7], [5], [7], [4], [5], [], [], [], []]
 Output
 [null, null, null, null, null, null, null, 5, 7, 5, 4]
 
 Explanation
 FreqStack freqStack = new FreqStack();
 freqStack.push(5); // The stack is [5]
 freqStack.push(7); // The stack is [5,7]
 freqStack.push(5); // The stack is [5,7,5]
 freqStack.push(7); // The stack is [5,7,5,7]
 freqStack.push(4); // The stack is [5,7,5,7,4]
 freqStack.push(5); // The stack is [5,7,5,7,4,5]
 freqStack.pop(); // return 5, as 5 is the most frequent. The stack becomes [5,7,5,7,4].
 freqStack.pop(); // return 7, as 5 and 7 is the most frequent, but 7 is closest to the top. The stack becomes [5,7,5,4].
 freqStack.pop(); // return 5, as 5 is the most frequent. The stack becomes [5,7,4].
 freqStack.pop(); // return 4, as 4, 5 and 7 is the most frequent, but 4 is closest to the top. The stack becomes [5,7].
 
 
 Constraints:
 
 0 <= val <= 109
 At most 2 * 104 calls will be made to push and pop.
 It is guaranteed that there will be at least one element in the stack before calling pop.
8. Max subarray in the array
 一个array找到最大的subarray的加和。
9. Design snapshot tool
设计一个snapshot类,是三个接口: void add(int n); int makesnapshot(); bool exists(int n, int snapshotid)
10. Design code test system
设计题:设计一个让用户对于code change提交test并且查询test情况的系统,以及一个如何把长url缩成一个tinyurl。
 ‍‍‌‌‌‌‍‍‍‍‍‌
11. Find bug in code
for(int row=0;row<1024;row++){
 
 if(row&3==0){
 
 printf("blabla");
 
 }
 
 }
 
 }
 
 这段代码的用意是每4个数输出一个值。
 
 找bug