记录下第一次实习面试的经历
腾讯微信事业群,约在了周四下午四点钟,时间到了之后面试官打电话说会发几道算法题过来,一个小时以后发送给他,一共4道题
前三个题有思路,第四个题目没有思路;
之后电话面试中问了一些跟vue、javascript相关的知识
具体题目如下
算法题
- 把0移动到数组后面
Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements.
For example, given nums = [0, 1, 0, 3, 12], after calling your function, nums should be [1, 3, 12, 0, 0].
Note:
You must do this in-place without making a copy of the array.
Minimize the total number of operations.
2.合并二叉树
Given two binary trees and imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are not.
You need to merge them into a new binary tree. The merge rule is that if two nodes overlap, then sum node values up as the new value of the merged node. Otherwise, the NOT null node will be used as the node of new tree.
Example 1:
Input:
Tree 1 Tree 2
1 2
/ \ / \
3 2 1 3
/ \ \
5 4 7
Output:
Merged tree:
3
/
4 5
/ \ \
5 4 7
Note: The merging process must start from the root nodes of both trees.
- 页面page的主函数入口在page.js,以下为其依赖树。
为了性能要求我们页面会组装一个combo请求:http://res.wx.qq.com/F.js,E.js,D.js,C.js,B.js,A.js,page.js,每个js文件都是用自运行匿名函数包裹起来,服务器端按顺序把js文件合并后返回。
请设计gen_url(requireTree),返回值会如上所示的combo url。
requireTree的数据结构如下页。
requireTree = {
"name": "page.js",
"require": [{
"name": "A.js",
"require": [{
"name": "C.js",
"require": [{
"name": "F.js"
}]
}]
}, {
"name": "B.js",
"require": [{
"name": "D.js",
"require": [{
"name": "F.js"
}]
}, {
"name": "E.js",
"require": []
}]
}]
}
4、算出字符串的重复数量
Define S = [s,n] as the string S which consists of n connected strings s. For example, ["abc", 3] ="abcabcabc".
On the other hand, we define that string s1 can be obtained from string s2 if we can remove some characters from s2 such that it becomes s1. For example, “abc” can be obtained from “abdbec” based on our definition, but it can not be obtained from “acbbe”.
You are given two non-empty strings s1 and s2 (each at most 100 characters long) and two integers 0 ≤ n1 ≤ 106 and 1 ≤ n2 ≤ 106. Now consider the strings S1 and S2, where S1=[s1,n1] and S2=[s2,n2]. Find the maximum integer M such that [S2,M] can be obtained from S1.
Example:
Input:
s1="acb", n1=4
s2="ab", n2=2
Return:
2
1.测试跟前端相关的东西
2.浏览器渲染过程
3.vue原理,自己选一个说,问到了nextTick
4.闭包原理
5.js捕获异常的方式 除了try...catch
6.javascript脚本放到 title标签中,会不会阻塞加载
7.算法题3的应用
8.暂时就这么多