<
回复: 3
收起左侧

fast.co Karat 面经

匿名用户-LDGCX  2021-12-30 06:58:44
本楼:   👍  0
0%
0%
0   👎

2021(10-12月) 码农类General 硕士 全职@fast.co - 内推 - 技术电面  | 😃 Positive 😐 AverageFail | 在职跳槽

注册一亩三分地论坛,查看更多干货!

您需要 登录 才可以下载或查看附件。没有帐号?注册账号

x
Fast.co 面试,用的 Karat

先是5题像是 system design的题。
1. 如果有200个相同的 Instance,每过几分钟就会有一台机器宕机。 问都有可能是什么原因
2. 一个图里有 http code 2xx, 3xx, 4xx, 5xx,的几条线,纵坐标是 query per second, 5xx 的线有几个 peak。问发生了什么
3. 一个图显示有API latency, 问怎么办



两题 coding:

reflow字符串
1. word wrap
给一个word list 和最大的长度,要求把这些word用 - 串联起来,但不能超过最大的长度。
We are building a word processor and we would like to implement a "word-wrap" functionality.


Given a list of words followed by a maximum number of characters in a line, return a collection of strings where each string element represents a line that contains as many words as possible, with the words in each line being concatenated with a single '-' (representing a space, but easier to see for testing). The length of each string must not exceed the maximum character length per line.


Your function should take in the maximum characters per line and return a data structure representing all lines in the indicated max length.


Examples:

words1 = [ "The", "day", "began", "as", "still", "as", "the",
          "night", "abruptly", "lighted", "with", "brilliant",
          "flame" ]

wrapLines(words1, 13) "wrap words1 to line length 13" =>

  [ "The-day-began",
    "as-still-as",
    "the-night",
    "abruptly",
    "lighted-with",
    "brilliant",
    "flame" ]

wrapLines(words1, 20) "wrap words1 to line length 20" =>

  [ "The-day-began-as",
    "still-as-the-night",
    "abruptly-lighted",
    "with-brilliant-flame" ]

words2 = [ "Hello" ]

wrapLines(words2, 5) "wrap words2 to line length 5" =>

  [ "Hello" ]

words3 = [ "Hello", "world" ]

wrapLines(words3, 5) "wrap words3 to line length 5" =>

  [ "Hello",
  "world" ]

words4 = ["Well", "Hello", "world" ]

wrapLines(words4, 5) "wrap words4 to line length 5" =>

  [ "Well",
  "Hello",
  "world" ]

words5 = ["Hello", "HelloWorld", "Hello", "Hello"]

wrapLines(words5, 20) "wrap words 5 to line length 20 =>

  [ "Hello-HelloWorld",
    "Hello-Hello" ]

"""

words1 = ["The","day","began","as","still","as","the","night","abruptly","lighted","with","brilliant","flame"]
line_length_1_1 = 13
line_length_1_2 = 20

words2 = ["Hello"]
line_length_2_1= 5

words3 = ["Hello", "world"]
line_length_3_1 = 5

words4 = ["Well", "Hello", "world"]
line_length_4_1 = 5

words5 = ["Hello", "HelloWorld", "Hello", "Hello"]
line_length_5_1 = 20

# Note: built-in functions like the Python textwrap module should not be used as solutions to this problem. function wordWrap(words, maxLen) {
  if (!words || words.l
您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限查看其他获取积分的方式
i < words.length) {
      if (remain - words[i].length < 0) {
        break;
      }
      count++;
      remain -= words[i++].length + 1;
    }
    const line = words.slice(i - count, i);

    // after splitting into lines, calculate the required dashes between each word
    const n = line.reduce((n, word) => n + word.length, 0);
    let reflowed = ''; // line result with padded dashes
    const baseDash = '-'.repeat(parseInt((maxLen - n) / (line.length - 1)));
    let extra = (maxLen - n) % (line.length - 1); // some dashes at the beginning has one extra dash
    for (let j = 0; j < line.length; j++) {
      if (j === line.length - 1) {
        reflowed += line[j];
      } else {
        reflowed +=
          extra-- <= 0 ? line[j] + baseDash : line[j] + baseDash + '-';
      }
    }
    result.push(reflowed);
  }
  return result;
}




上一篇:领英电面跪经
下一篇:chartmetric zoom面
MutouMan 2022-1-8 00:40:55 | 显示全部楼层
本楼:   👍  0
0%
0%
0   👎
全局:   1402
98%
2%
27
马上也要面他们家,楼主去了吗
回复

使用道具 举报

Klauss 2022-1-17 10:34:41 | 显示全部楼层
本楼:   👍  0
0%
0%
0   👎
全局:   13
100%
0%
0
MutouMan 发表于 2022-1-7 08:40
马上也要面他们家,楼主去了吗

能update一下面了什么问题吗?
扫码关注一亩三分地求职移民公众号
更多干货内容等你发现
回复

使用道具 举报

MutouMan 2022-1-19 08:04:09 | 显示全部楼层
本楼:   👍  0
0%
0%
0   👎
全局:   1402
98%
2%
27
Klauss 发表于 2022-1-16 21:34
能update一下面了什么问题吗?

https://www.1point3acres.com/bbs/thread-840480-1-1.html 更新在这儿了
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册账号
隐私提醒:
  • ☑ 禁止发布广告,拉群,贴个人联系方式:找人请去🔗同学同事飞友,拉群请去🔗拉群结伴,广告请去🔗跳蚤市场,和 🔗租房广告|找室友
  • ☑ 论坛内容在发帖 30 分钟内可以编辑,过后则不能删帖。为防止被骚扰甚至人肉,不要公开留微信等联系方式,如有需求请以论坛私信方式发送。
  • ☑ 干货版块可免费使用 🔗超级匿名:面经(美国面经、中国面经、数科面经、PM面经),抖包袱(美国、中国)和录取汇报、定位选校版
  • ☑ 查阅全站 🔗各种匿名方法

本版积分规则

Advertisement
>
快速回复 返回顶部 返回列表