当前位置: 首页 > 面试经验 >

血泪教训:投大厂,要趁早(阿里前端一面凉经)

优质
小牛编辑
79浏览
2023-03-28

血泪教训:投大厂,要趁早(阿里前端一面凉经)




8.30  投简历


投晚了,阿里校招刚出的时候感觉还没准备好,打算再攒攒面经刷刷题

后面才知道,时间不等人,在你犹豫的同时别人已经上车了,座位就会少一个


9.6  19:30 一面(≈60min)



属于是电话面吧?


面试开始前5分钟面试官给发了个链接,里面有道代码题


到点了面试官就打电话过来了,说先做一下这个题


// 补全以下代码,使得程序能够给定4个数字,输出能计算出24的四则运算方法(加减乘除与括号)

var operations = {
  '+': (a, b) => a + b,
  '-': (a, b) => a - b,
  '*': (a, b) => a * b,
  '/': (a, b) => a / b,
}

function get24(a, b, c, d) {
  for (const num of getNumbers([a, b, c, d])) {
    for (const op of getOperators(['+', '-', '*', '/'])) {
      if (
        is24(
          operations[op[2]](
            operations[op[1]](
              operations[op[0]](num[0], num[1]),
              num[2]
            ),
            num[3]
          )
        )
      ) {
        return '((' + num[0] + op[0] + num[1] + ')' + op[1] + num[2] + ')' + op[2] + num[3]
      }
      if (
        is24(
          operations[op[0]](
            num[0],
            operations[op[1]](
              num[1],
              operations[op[2]](num[2], num[3])
            )
          )
        )
      ) {
        return num[0] + op[0] + '(' + num[1] + op[1] + '(' + num[2] + op[2] + num[3] + '))'
      }
      if (
        is24(
          operations[op[0]](
            operations[op[1]](
              num[0],
              num[1]
            ),
            operations[op[2]](
              num[2],
              num[3]
            )
          )
        )
      ) {
        return '(' + num[0] + op[1] + num[1] + ')' + op[0] + '(' + num



 类似资料: