注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号 
x
职位:Software Engineer
------------------------------------
P1
1、[Web] 给定一个最简单的博客系统,根据 RESTful 面向资源的设计思想,设计请求路径。
涉及问题一:HTTP 有多少种请求方法?
GET - Requests data from a specified resource
POST - Submits data to be processed to a specified resource
PUT - Uploads a representation of the specified URI
DELETE - Deletes the specified resource
HEAD - Same as GET but returns only HTTP headers and no document body
OPTIONS - Returns the HTTP methods that the server supports
参考设计:
1)用户登录:[POST] /users/session
2)用户登出:[DELETE] /users/session
3)文章列表:[GET] /articles
4)增加一篇:[PUT] /artibles
5)读取一篇:[GET] /articles/id
6)删除一篇:[DELETE] /articles/id
2、[Web] 为什么浏览器不允许 Ajax 跨域请求?
原因:不安全。
因为 HTTP 是无状态协议。即每次请求都相互独立。
如果设置了 Cookie, 发生请求时 Cookie 被包含在请求头中。
这样别的域的服务器会得到 Cookie 信息。
如果在 Cookie 存放 session-id,将会引起安全漏洞。
3、[Shell] 给定一个格式的文件 file1.log:
name title value
xxx xxx 1
xxx xxx 1
xxx xxx 3
xxx xxx 1
xxx xxx 2
xxx xxx 1
请用 shell 命令计算出 value 的总数:sum(value)
考察点:管道运算符:|
参考: cat file1.log | calcuate-single-line
P2
1、[Algorithm]
给定一个 random() 函数,它的范围是 1 <= x <= 7,且是浮点数。
请写一个方法,产生 2 <= x <= 5 的函数。
function random2to5(){
return 2 + (random() - 1)/ 6 * 3;
}
思路:
先使 random() 的产值范围等于:0 <= x <= 1
2、1)介绍一下 MapReduce ?
2)给定一个文件流(长度非常大),提供 readLine() 方法,
每次只读一行。读到值为 null 文件
return i;
}else{
newArr[i] = i;
}
}
return null;
}
2、[Algorithm]
接上题目:
假如系统内存有限,所要排序的数组不能全部被加载到内存中,
数组数据只能保存在磁盘中,如何找出?
参考:
对磁盘中的数据使用外部排序的方法,先排好序,再找。
提示:
快速排序 和 归并排序 都可以用作外部排序( External Sorting)。
平均时间复杂度: ( N + 1) * log N
考察点:
1)空间复杂度为 O(1) 的算法
2)External Sorting
3、[Algorithm]
接上题目:
假如系统内存有限,磁盘存储空间也有限。
要排序的数据在另外一台机器上,且只提供一个方法 queryByIndex(i)
请找出重复的那个数据?
for(int i = 0; i <= n - 1; i++){
int tempI = queryByIndex(i);
for(int j = i + 1; j <= n - 1; j++){
if(tempI == queryByIndex(j) ) return tempI;
}
}
时间复杂度: n * n
对于已跪的结果,发出来希望对他人有所帮助。且行且珍惜
欢迎补充
谢谢各位!
|