回复: 5
跳转到指定楼层
上一主题 下一主题
收起左侧

stripe phone screen 挂经

🔗
匿名用户-YAWVK  2021-10-14 07:19:05 来自APP |倒序浏览

2021(7-9月) 码农类General 硕士 全职@stripe - 校园招聘会 - 技术电面  | 😃 Positive 😐 Average | Fail | 应届毕业生

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

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

x
今天收到拒信 更新一下地里挺难找的stripe的phone screen。
面到的并不是http的题目 而是一道判断server的remove时间与对应的penalty的题。
1.a是给你一个由0与1组成的string 然后让输入一个时间去remove这个server,让你计算这个情况下penalty的大小。 penalty的计算规则为:
在一个string中, 0意味着这时候德server应该正常运行,1意味着这时候的server会d
您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限 或 查看其他获取积分的方式
Unlock interview details and practice with AI
Curated Interview Questions from Top Companies
ool来判断每次遇到END的时候前面是不是有open的BEGIN,有的话那中间的content就可以用1.b算出结果,然后再把bool复位到false即可。

到2.a的时候思路卡壳了,加之前面和小哥交流花了点时间,遂卒。 祝各位好运。

评分

参与人数 2大米 +9 收起 理由
匿名用户-UEP7G + 8
Excal1p2 + 1 很有用的信息!

查看全部评分


上一篇:Google ng timeline
下一篇:狗家虚拟表演现场
地里匿名用户
🔗
匿名用户-4EXO6  2021-10-14 07:39:56 来自APP
请问投了过后多久收到oa和电面的呢?谢谢!
回复

使用道具 举报

地里匿名用户
🔗
匿名用户-73FP5  2021-10-16 02:29:02
Share a solution to crash stripe will you please give 评分加米

  1. import java.util.*;

  2. public class RemoveServe {

  3.   /*
  4.     Question comes from
  5.      https://www.1point3acres.com/bbs/thread-780948-1-1.html
  6.      https://1o24bbs.com/t/topic/5821/10
  7.      https://www.1point3acres.com/bbs/thread-802334-1-1.html

  8.     Part 1
  9.             Given logs and removed_time calculate the total penalty score
  10.             logs consist of 0 and 1 in one string
  11.             ex) "0 0 0 1 0 0"
  12.             0 means the server was up and running
  13.             1 means the server was down and not functioning

  14.             if the server is taken down too early you get a +1 penalty for reach the running server
  15.             after removed_time
  16.             if the server is taken down too late, you get a +1 penalty for reach a server that was
  17.             down before removed_time

  18.             Example 1

  19.             "0 0 1 0" remove_time = 2 (0 based index)
  20.             when the server is shut down, there is a penalty of 1 since during time 3rd and 4th
  21.             log 4th indicated it was on when it should have been off.
  22.             penalty = 1

  23.             Example 2
  24.             "0 0 1 0" remove_time = 0 index
  25.             penalty = 3
  26.             log 1st, 2nd, 4th was on when it should have been off

  27.             Example 3
  28.             "1 1 1 0" remove_time = 0 index
  29.             penalty = 1
  30.             only log 4th was on when it should have been off

  31.     Part 2
  32.             write another function to give logs find when is the best time to take the server down

  33.             Example
  34.             log "1 1 1 0"
  35.             best_time = 0  0-based index
  36.             because for time 1 2 3 4 penalties will be 2 3 4 3
  37.             at time 1th penalty is 1 which is the lowest

  38.             log   "1 0 0"
  39.                    0 1 1
  40.                    2 2 1
  41.            penalty 2 3 2, there 2 time with the lowest penalty,
  42.           how to select now: index 0 or 2 ??

  43.   Part 3

  44.             write another function which can take in logs
  45.             this time with 'BEGIN' 'END' '0' '1' '\n'
  46.             they can be out of order
  47.             There are no nested loops

  48.             ex) 'BEGIN END BEGIN BEGIN 1 0 0 END END 0 0 1'
  49.             The only valid sequence is
  50.                                  BEGIN 1 0 0 END
  51.             It must start with BEGIN and ‍‌‍‌‌‍‌‌‍‍‌‍‍‌‍‍‌‌end with END
  52.             There can be multiple valid sequences,
  53.             return a list of the best times to take the server down

  54.             Example 1
  55.             "BEGIN BEGIN 1 0 0 END"
  56.             return [2] 1-based index
  57.             because the valid sequence is "1 0 0" now use
  58.             the function we wrote in part 2 and return  it in a list.

  59.             Example 2  1-based index
  60.             "BEGIN BEGIN 1 0 0 END 0 0 0 1 BEGIN 1 1 1 0 END"
  61.             return [2, 0]
  62.             valid sequence is "1 0 0" and "1 1 1 0"*/

  63.   public static int getPenalty(String line, int removed) {
  64.     if (line == null || line.length() == 0) return 0;
  65.     String[] digits = line.split("\\s");
  66.     int r = 0;
  67.     for (int i = 0; i < digits.length; i++) {
  68.       if ((i < removed && digits[i].equals("1")) || (i >= removed && digits[i].equals("0"))) {
  69.         r++;
  70.       }
  71.     }
  72.     return r;
  73.   }

  74.   public static int bestTimeToShutDown(String line) {
  75.     if (line == null || line.length() == 0) return -1;

  76.     String[] digits = line.split("\\s");
  77.     int N = digits.length;
  78.     int[] nozero = new int[N];
  79.     int nozSum = 0;
  80.     for (int i = 1; i < N; i++) {
  81.       if (digits[i - 1].equals("1")) nozSum++;
  82.       nozero[i] = nozSum;
  83.     }
  84.     int minP = Integer.MAX_VALUE, r = -1;
  85.     int no1 = 0;
  86.     for (int i = N - 1; i >= 0; i--) {
  87.       if (digits[i].equals("0")) no1++;
  88.       if (no1 + nozero[i] < minP) {
  89.         minP = no1 + nozero[i];
  90.         r = i;
  91.       }
  92.     }
  93.     return r;
  94.   }

  95.   public static List<Integer> parseLogs(String line) {
  96.     String[] cuts = line.split("\\s");
  97.     int start = -1, end = -1;
  98.     int i = 0;
  99.     List<String> logs = new ArrayList<>();
  100.     while (i < cuts.length) {
  101.       if (i > 0 && cuts[i].length() == 1 && Character.isDigit(cuts[i].charAt(0))) {
  102.         start = i - 1;
  103.         StringBuilder s = new StringBuilder();
  104.         while (i < cuts.length && cuts[i].length() == 1 && Character.isDigit(cuts[i].charAt(0))) {
  105.           s.append(cuts[i]).append(" ");
  106.           i++;
  107.         }
  108.         if (i < cuts.length && cuts[i].equals("END") && cuts[start].equals("BEGIN")) {
  109.           logs.add(s.toString());
  110.         }
  111.       } else {
  112.         i++;
  113.       }
  114.     }
  115.     List<Integer> r = new LinkedList<>();
  116.     for (String log : logs) {
  117.       r.add(bestTimeToShutDown(log));
  118.     }
  119.     return r;
  120.   }

  121.   public static void main(String[] args) {
  122.     System.out.println(getPenalty("0 0 1 0", 2) == 1);
  123.     System.out.println(getPenalty("0 0 1 0", 0) == 3);
  124.     System.out.println(getPenalty("1 1 1 0", 0) == 1);

  125.     System.out.println(bestTimeToShutDown("1 1 1 0") == 0);
  126.     System.out.println(bestTimeToShutDown("0 0 1 0") == 2);
  127.     System.out.println(bestTimeToShutDown("1 1 0") == 0);
  128.     System.out.println(bestTimeToShutDown("1 0 0") == 2); // 0 or 2

  129.     System.out.println(
  130.         Arrays.toString(parseLogs("BEGIN END BEGIN BEGIN 1 0 0 END END 0 0 1").toArray())
  131.             .equals("[2]"));
  132.     System.out.println(Arrays.toString(parseLogs("BEGIN BEGIN 1 0 0 END").toArray()).equals("[2]"));
  133.     System.out.println(
  134.         Arrays.toString(parseLogs("BEGIN BEGIN 1 0 0 END 0 0 0 1 BEGIN 1 1 1 0 END").toArray())
  135.             .equals("[2, 0]"));
  136.   }
复制代码

评分

参与人数 3大米 +9 收起 理由
匿名用户-UEP7G + 5
优优呦呦5 + 1 欢迎分享你知道的情况,会给更多积分奖励!
stultus + 3 很有用的信息!

查看全部评分

回复

使用道具 举报

全局:
Phone screen 是那个oa之后的一轮店面吗
回复

使用道具 举报

🔗
oxygen300 2021-10-20 03:02:07 | 只看该作者
全局:
When did you apply online? I heard they are full for interns. Is it true?
回复

使用道具 举报

地里匿名用户
🔗
匿名用户-DNJ5D  2021-11-9 05:31:47
本帖最后由 匿名 于 2021-11-8 14:13 编辑

这个实现have bug吧。 100 的最佳移除时机是3, 也就是4小时的地方,其惩罚因子是1
回复

使用道具 举报

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

本版积分规则

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