微软小冰面试

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接: https://blog.csdn.net/weixin_43251291/article/details/102506225
A 必做题

1. for循环从1-5, js 实现

for (var i=1;i <=5;i++){
	console.log(i)
}

**2. **

B 选做题

3. 从两个字符串中选出最长的公共字符串

def getLCString(str1,str2):
	# 最大长度
	maxlen = len(str1) if len(str1) < len(sre2) else len(sre2)
	# 最小长度字符串
	example = str1 if len(str1) < len(str2) else str2
	# 
	other = str2 if str1 == example else str1
	for i in range(maxlen):
		for j in range(maxlen, 0, -1):
			if other.find(example[i:j] != -1:
				return example[i:j]

4. 遍历二叉树

class TreeNode(object):
	def __init__(self, left=None, right=None, data=None):
		self.data = data
		self.left = left
		self.right = right
	def preorder(root):
		if root:
			print(root.data)
			preorder(root.left)
			preorder(root.right)
	def midorder(root):
		if root:
			migorder(root.left)
			print(root.data)
			midorder(root.right)
	def postorder(root):
		if root:
			posrorder(root.left)
			posrorder(root.right)
			print(root.data)

5. 给前端填颜色
6. 实现一个table,用js实现

猜你喜欢

转载自blog.csdn.net/weixin_43251291/article/details/102506225