📣 Back to School开学季 - VIP通行证5折优惠!蓝莓、Offer多多同步优惠
回复: 4
跳转到指定楼层
上一主题 下一主题
收起左侧

Amazon OA 面试经验

全局:

2020(10-12月) 码农类General 硕士 全职@amazon - 猎头 - 在线笔试  | | Fail | 在职跳槽

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

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

x
Utilization Checks :
其中一个测试案例是:[46, 73, 77, 53, 75, 22, 55, 84, 45, 40, 80, 66, 54, 39, 68, 23, 54, 22, 11, 91, 47, 56, 91, 97, 5, 44, 62, 73, 26, 99, 96, 74, 4
您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限查看其他获取积分的方式
Unlock interview details and practice with AI
Curated Interview Questions from Top Companies
单的那些外,马上上到500个长度的startIndices,要确保你的代码是O(n+m)的复杂度。我考完后修改的代码:
  1.     public static List<Integer> numberOfItems(String s, List<Integer> startIndices, List<Integer> endIndices) {
  2.         List<Integer> result = new ArrayList<>();
  3.         
  4.         if (s == null || s.isEmpty()) {
  5.             return result;
  6.         }
  7.         
  8.         char[] charArray = s.toCharArray();
  9.         List<Integer> pipePositions = new ArrayList<>();
  10.         int[] nextIndexInPipePositions = new int[charArray.length]; //for each character in the string, the valid counting point will be from the position indicated by the index of pipePositions. for example, "**|**|" the pipePositions will be [2,5] and nextIndexInPipePositions will be [0,0,0,1,1,1] indicating [2,2,2,5,5,5]
  11.         for (int i = 0; i < charArray.length; i++) {
  12.             nextIndexInPipePositions[i] = pipePositions.size();
  13.             if (charArray[i] == '|') {
  14.                 pipePositions.add(i);
  15.             }
  16.         }
  17.         
  18.         int indicesSize = Math.min(startIndices.size(), endIndices.size());
  19.         for (int i = 0; i < indicesSize; i++) {
  20.             int firstPipePositionIndex = nextIndexInPipePositions[startIndices.get(i) - 1];
  21.             int lastPipePositionIndex = nextIndexInPipePositions[endIndices.get(i) - 1];
  22.             if (charArray[endIndices.get(i) - 1] != '|') { //the next pipe is after the endIndex - should count to the previous pipe
  23.                 lastPipePositionIndex--;
  24.             }
  25.             if (lastPipePositionIndex > firstPipePositionIndex) {
  26.                 // count of *s = the total distance between the first pipe and the last pipe - the pipe count between the fist piple and the last pipe
  27.                 result.add(pipePositions.get(lastPipePositionIndex) - pipePositions.get(firstPipePositionIndex) - lastPipePositionIndex + firstPipePositionIndex);
  28.             } else { // no pipe or only one pipe between
  29.                 result.add(0);
  30.             }
  31.         }
  32.         
  33.         return result;
  34.     }
复制代码



评分

参与人数 6大米 +8 收起 理由
lapin + 1 给你点个赞!
caesar5877 + 2 给你点个赞!
SxSxSxSx + 1 很有用的信息!
JervisC + 2 给你点个赞!
Susuz + 1 给你点个赞!

查看全部评分


上一篇:Square OA 面经
下一篇:roblox第三方电面
🔗
沉-CS 2020-11-28 07:24:56 | 只看该作者
全局:
楼主能贴一下starting instance 和最后expected output instances# 么?
回复

使用道具 举报

🔗
 楼主| user2198M 2020-11-30 13:29:25 | 只看该作者
全局:
您好!
本帖隐藏的内容需要积分高于 100 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 100 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限查看其他获取积分的方式
Unlock interview details and practice with AI
Curated Interview Questions from Top Companies

评分

参与人数 1大米 +1 收起 理由
SxSxSxSx + 1 很有用的信息!

查看全部评分

回复

使用道具 举报

🔗
沉-CS 2020-12-8 07:36:54 | 只看该作者
全局:
谢谢楼主, 可能我没说清楚, 我问的是你的第一题 Utility check 的  long case [46, 73, 77, 53, 75, 22,  ....
starting number of instance 是多少, expected output instance 是多少?
回复

使用道具 举报

🔗
5222464 2021-1-6 11:17:13 | 只看该作者
全局:
楼主可以讲讲第二题的思路吗 可以binary search做吗
回复

使用道具 举报

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

本版积分规则

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