📣 独立日限时特惠: VIP通行证立减$68
回复: 16
跳转到指定楼层
上一主题 下一主题
收起左侧

LinkedIn 电面

全局:

2014(7-9月) 码农类General 硕士 全职@linkedin - 网上海投 - 技术电面  | | Other |

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

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

x
下午电面linkedin,题目:

1. given array which is sorted and rota
您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限查看其他获取积分的方式
Unlock interview details and practice with AI
Curated Interview Questions from Top Companies
开始rotate的点得位置--> 2 (也就是1得位置)


上一篇:snapchat onsite面试
下一篇:LinkedIn一面攒人品
推荐
tiexiong 2014-8-1 02:58:38 | 只看该作者
全局:
第一题要注意Duplicates or not,写之前沟通好就行。我写了一个,是否有Duplicates都可以处理,通过LeetCode.

    public static boolean findSearchInRotatedSortedArray(int[] A, int target) {
        if (A == null || A.length < 1)
            return false;
        
        int L = 0;
        int R = A.length - 1;
        
        while (L <= R) {
            int M = (L + R) / 2;
            if (A[M] == target)
                return true;
            
            if (A[L] < A[M]) {
                if (A[L] <= target && target < A[M]) {
                    R = M - 1;
                } else {
                    L = M + 1;
                }
            } else if (A[L] > A[M]){
                if (A[M] < target && target <= A[R]) {
                    L = M + 1;
                } else {
                    R = M - 1;
                }
            } else {
                L++;
            }
        }
        return false;
    }

回复

使用道具 举报

推荐
tiexiong 2014-8-1 03:03:40 | 只看该作者
全局:
刚才的代码未能正常显示
  1. public static boolean findSearchInRotatedSortedArray(int[] A, int target) {
  2.         if (A == null || A.length < 1)
  3.             return false;
  4.         
  5.         int L = 0;
  6.         int R = A.length - 1;
  7.         
  8.         while (L <= R) {
  9.             int M = (L + R) / 2;
  10.             if (A[M] == target)
  11.                 return true;
  12.             
  13.             if (A[L] < A[M]) {
  14.                 if (A[L] <= target && target < A[M]) {
  15.                     R = M - 1;
  16.                 } else {
  17.                     L = M + 1;
  18.                 }
  19.             } else if (A[L] > A[M]){
  20.                 if (A[M] < target && target <= A[R]) {
  21.                     L = M + 1;
  22.                 } else {
  23.                     R = M - 1;
  24.                 }
  25.             } else {
  26.                 L++;
  27.             }
  28.         }
  29.         return false;
  30.     }
复制代码
回复

使用道具 举报

推荐
tiexiong 2014-8-1 03:08:37 | 只看该作者
全局:
第二题要注意duplicates,是否rotate,以下是我的code。
  1.     public static int findSmallestElement(int[] A) {
  2.         if (A == null || A.length < 2) // null, empty and one element.
  3.             return 0;

  4.         int L = 0;
  5.         int R = A.length - 1;
  6.         
  7.         if (A[R] > A[L]) // No rotation.
  8.             return A[L];

  9.         while (L < R) {
  10.             int M = (L + R) / 2;
  11.             if (L == M)
  12.                 return M + 1; // Finally the loop will reach L = M, then A[M + 1] should be the smallest element.
  13.             
  14.             if (A[L] < A[M]) { // Left is smaller than middle, then search the right half array including current middle element.
  15.                 L = M; // Not L = M + 1.
  16.             } else if (A[L] > A[M]) { // Left is greater than middle, then search the left half array including current middle element.
  17.                 R = M; // Not R = M + 1.
  18.             } else { // Left is the same as middle, just increment left pointer by one.
  19.                 L++;
  20.             }
  21.         }
  22.         return 0;
  23.     }
复制代码
回复

使用道具 举报

🔗
readman 2014-7-30 14:19:15 | 只看该作者
全局:
1.双调搜索.
2. 同上
回复

使用道具 举报

🔗
mkcing 2014-7-30 14:20:45 | 只看该作者
全局:
第二个问题 开始rotate的点的位置是不是最小值的点?

另外这个面试持续了多长时间?
回复

使用道具 举报

🔗
rengokantai 2014-7-30 22:06:07 | 只看该作者
全局:
楼主运气不错,地里有个linkedin的电面比你的难N倍
回复

使用道具 举报

🔗
yzl232 2014-7-30 22:24:18 | 只看该作者
全局:
稍微变化的binary search  
这题不难啊
回复

使用道具 举报

🔗
readman 2014-7-30 22:27:25 | 只看该作者
全局:
yzl232 发表于 2014-7-30 22:24
稍微变化的binary search  
这题不难啊

双调的bs 直接写很容易写bug
回复

使用道具 举报

🔗
yzl232 2014-7-30 22:31:10 | 只看该作者
全局:
readman 发表于 2014-7-30 22:27
双调的bs 直接写很容易写bug

leetcode  原题。。。
回复

使用道具 举报

🔗
readman 2014-7-30 22:39:56 | 只看该作者
全局:
yzl232 发表于 2014-7-30 22:31
leetcode  原题。。。

啊?> 哪个?

补充内容 (2014-7-30 23:47):
- = 找到了
回复

使用道具 举报

🔗
wendychueng 2014-7-31 02:40:08 | 只看该作者
全局:
readman 发表于 2014-7-30 09:39
啊?> 哪个?

补充内容 (2014-7-30 23:47):

请问哪一题啊
回复

使用道具 举报

🔗
readman 2014-7-31 08:48:19 | 只看该作者
全局:

rotate array
回复

使用道具 举报

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

本版积分规则

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