<
回复: 5
收起左侧

亞麻新鮮 oa

本楼:   👍  0
0%
0%
0   👎
全局:   14
93%
7%
1

2023(7-9月) 码农类General 硕士 全职@amazon - 猎头 - 在线笔试  | 😃 Positive 😣 HardPass | 在职跳槽

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

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

x
新鮮oa

原題
Amazon has multiple delivery centers and delivery warehouses all over the world! The world is represented by a number line from -109 to 10°
. There are n delivery centers,
the ith one at location center[i]. A location x is called a suitable location for a warehouse if it is possible to bring all the products to that point by traveling a distance of no more than d. At any one time, products can be brought from one delivery center and placed at point x. Given the positions of n delivery centers, calculate the number of suita
您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限查看其他获取积分的方式
864%2FAmazon-OA" rel="nofollow noopener" target="_blank">https://leetcode.com/discuss/interview-question/3949864/Amazon-OA

這題沒做出來,但今天說pass 了
希望有幫助到

上一篇:Nextdoor 2024 Summer MLE Intern面经 求米
下一篇:高盛 engineering OA
stxfd123 2023-10-26 05:31:16 | 显示全部楼层
本楼:   👍  1
100%
0%
0   👎
全局:   299
100%
0%
0
本帖最后由 stxfd123 于 2023-10-25 14:36 编辑

我有一个新的思路,我先从 最左边的那个点左方距离 target 除以 2 的地方开始。计算此刻到所有点的距离sum, 然后从这个点依次向右走,每往右走一个点,sum 减去 1 * right_count . 如果遇到一个仓库 right_count - 1, left_cout + 1,那么继续往右走的时候 sum - 1 * right_count  + 1 * left_count , 用这样的方法一直走到 sum * 2==  target.
在走的过程中计数
复杂度 是 linear
回复

使用道具 举报

地里匿名用户
匿名用户-ULLU4  2023-9-29 09:49:28
本楼:   👍  1
100%
0%
0   👎
static int ans = 0;
   
    public static int getN(int[] centers, int d){
        int min = Integer.MAX_VALUE;
        int max = Integer.MIN_VALUE;
        for(int c:centers){
            if(min > c)
                min = c;
            if(max < c)
                max = c;
        }
        
        int l = min - d;
        int r = d + max;
        find(l, r, centers, d);

        return ans;
    }
   
    public static void find(int l, int r, int[] centers, int d){
        if(l<=r){
            int mid = l + (r-l)/2;
            int m = calculate(centers, mid);
            if(m <=d)
                ans++;
            find(l,mid-1, centers, d);
            find(mid+1, r,centers, d);
        }
        
        
        
    }
回复

使用道具 举报

本楼:   👍  0
0%
0%
0   👎
全局:   3
60%
40%
2
全职开始发oa了吗?
回复

使用道具 举报

 楼主| bbkai2857 2023-9-26 03:46:21 | 显示全部楼层
本楼:   👍  0
0%
0%
0   👎
全局:   14
93%
7%
1
是的, Recruiter LinkedIn reach out
回复

使用道具 举报

finys 2023-10-8 03:45:27 | 显示全部楼层
本楼:   👍  0
0%
0%
0   👎
全局:   15
79%
21%
4
我也遇到了第二题,楼上的代码过了一半的test case, 其他tc 超时了。
static int ans = 0;
   
    public static int getN(int[] centers, int d){
        int min = Integer.MAX_VALUE;
        int max = Integer.MIN_VALUE;
        for(int c:centers){
            if(min > c)
                min = c;
            if(max < c)
                max = c;
        }
        
        int l = min - d;
        int r = d + max;
        find(l, r, centers, d);

        return ans;
    }
   
    public static void find(int l, int r, int[] centers, int d){
        if(l<=r){
            int mid = l + (r-l)/2;
            int m = calculate(centers, mid);
            if(m <=d)
                ans++;
            find(l,mid-1, centers, d);
            find(mid+1, r,centers, d);
        }
        
        
        
    }
回复

使用道具 举报

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

本版积分规则

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