前3个软件工程面试问题以及我提出的解决方案

During my software engineering career I was able to interview several developers including interns who were looking for a training program and also former engineers/newly graduated university students who were looking for a new position in their career. I thought to share solutions for technical questions that I asked frequently.

在我的软件工程职业生涯中,我采访了一些开发人员,包括正在寻找培训课程的实习生,以及正在寻找职业新职位的前工程师/刚毕业的大学生。 我想分享我经常问到的技术问题的解决方案。

“实用至上”的问题 (“Practical-first” questions)

When it comes to interview questions I would prefer practical questions(based of theoretical knowledge of course) over completely theoretical questions because anyone can answer a fully theoretical problem easily without having in-depth knowledge about the related theorem and without applying bit of a thinking. Following type A,B examples will differentiate it clearly,

当涉及面试问题时,相对于完全理论的问题,我更喜欢实际问题(当然是基于理论知识的问题),因为任何人都可以轻松地回答完全理论的问题,而无需对相关定理有深入的了解,也无需进行任何思考。 遵循A,B类型的示例可以清楚地区分它,

A: What is stack and how it works?

答:什么是堆栈及其工作原理?

B: How would you use stack to find all brackets are properly closed in getItem([[2,3],[10]])

B:您将如何使用堆栈来找到所有在getItem([[2,3],[10]])中正确括起来的括号

Q1 —上下文问题 (Q1 — The context problem)

Question: Modify the following code and call MainWindow.setIcon method from TitleBar.changeIcon method.

问题 :修改以下代码,然后从TitleBar.changeIcon方法调用MainWindow.setIcon方法。

class MainWindow {
  TitleBar tb;
  
  MainWindow() {
    tb = new TitleBar();
  }
  
  setIcon() {
  
  }


}


class TitleBar {
  changeIcon() {
  
  }
}

Solution: Many applicants asked from me “Can’t we simply create a new instance of MainWindow”. But the expected approach is to pass the context as per below.

解决方案 :许多申请人向我询问“我们不能简单地创建MainWindow的新实例”。 但是预期的方法是按照以下方式传递上下文。

class MainWindow {
  TitleBar tb;
  
  MainWindow() {
    tb = new TitleBar(this);
  }
  
  setIcon() {
  
  }


}


class TitleBar {
  MainWindow context;
  TitleBar(MainWindow ctx) {
    context = ctx;
  }
  
  changeIcon() {
    context.setIcon();
  }
}

Q2 — JSON问题 (Q2 — The JSON problem)

Question: Print all values v from following JSON object.

问题 :从以下JSON对象打印所有值v

{
   "a":{
      "a":{
         "v":20,
         "b":{
            "v":60
         }
      },
      "v":10
   },
   "b":{
      "b":{
         "v":70,
         "a":{
            "v":100
         }
      },
      "v":50
   },
   "v":12
}

Solution: Some people started with “nested for” loops. But the expected way is to use recursive function (in theory it’s binary tree traversal or knowledge from depth first search — dfs also can be applied)

解决方案 :有些人从“嵌套”循环开始。 但是预期的方式是使用递归函数(理论上,它是二叉树遍历或深度优先搜索的知识,也可以应用dfs )

J = {
   "a":{
      "a":{
         "v":20,
         "b":{
            "v":60
         }
      },
      "v":10
   },
   "b":{
      "b":{
         "v":70,
         "a":{
            "v":100
         }
      },
      "v":50
   },
   "v":12
};


function visitNode(n) {
  if(!n)
    return;
  console.log(n.v);
  visitNode(n.a);
  visitNode(n.b)
}


visitNode(J);

Q3 —阶乘问题 (Q3 — The factorial problem)

Question: Write a recursive function to return nth factorial and explain how it works referring stack frames in computer memory.

问题 :编写一个递归函数以返回nth阶乘,并解释其如何引用计算机内存中的堆栈帧。

Solution: I used to ask this from students who were going to be interns since this was covered university studies. I wrote a separate article for recursion which can be found here (it has the solution for this question).

解决方案 :我曾经问过要成为实习生的学生,因为这涵盖了大学学习。 我写了另一篇关于递归的文章,可以在这里找到(它有解决这个问题的方法)。

结论 (Conclusion)

Support practical-first type questions and if you an engineer who usually interviews developers please let them know answers for each coding questions eventually since it can be a good learning for their future interviews or for their software engineering career in your company.

支持实用型问题,如果您是一位通常与开发人员面谈的工程师,请最终让他们知道每个编码问题的答案,因为这对于他们将来的面试或您公司的软件工程职业都是很好的学习方法。

Happy coding 😎

快乐编码😎

翻译自: https://medium.com/softwareengineer-lk/top-3-software-engineering-interview-questions-with-solutions-asked-by-me-4765a4783858

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值