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

Zillow OA(附解答) 和 9月26第一轮电面

全局:

2016(7-9月) 码农类General 硕士 全职@zillow - 内推 - 技术电面  | | Pass | 应届毕业生

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

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

x
OA似乎是常见的两题
  1. Question 1) Given a string, write a routine that converts the string to a long, without using the
  2. built in functions that would do this. Describe what (if any) limitations the code has. For
  3. example:
  4. long stringToLong(String s)
  5. {
  6.      /* code goes here to convert a string to a long */
  7. }
  8. void test()
  9. {
  10. long i = stringToLong("123");. From 1point 3acres bbs
  11. if (i == 123)
  12. // success
  13. else
  14. // failure
  15. }
复制代码
  1. /*
  2.      * Complete the function below.
  3.      */
  4.     static long parseLong(String str) throws Exception {
  5.         if (str == null || str.length() == 0) {
  6.             throw new Exception("Invalid number.");
  7.         }
  8.         long result = 0;
  9.         int len = str.length();
  10.         boolean isPositive = true;
  11.         int start = 0; // first number

  12.         // check sign
  13.         if (str.charAt(start) == '+') {
  14.             isPositive = true;
  15.             start++;
  16.         } else if (str.charAt(start) == '-') {
  17.             isPositive = false;
  18.             start++;
  19.         }

  20.         // check if valid
  21.         if (start == len || (str.charAt(start) == '0' && start != len - 1)) {
  22.             throw new Exception("Invalid number.");
  23.         }

  24.         for (int i = start; i < len; i++) {
  25.             char c = str.charAt(i);
  26.             if (c >= '0' && c <= '9') {
  27.                 if (result > Long.MAX_VALUE / 10) {
  28.                     throw new Exception("Number overflow.");
  29.                 }
  30.                 if (result == Long.MAX_VALUE / 10 && i == len - 1) {
  31.                     if (isPositive && c > '7') {
  32.                         throw new Exception("Number overflow.");
  33.                     } else if (!isPositive && c > '8') {
  34.                         throw new Exception("Number Overflow.");
  35.                     } else if (!isPositive && c == '8') {
  36.                         return Long.MIN_VALUE;
  37.                     }
  38.                 }
  39.                 result = result * 10;
  40.                 result += (long) (c - '0');
  41.             } else {
  42.                 throw new Exception("Invalid number.");
  43.             }
  44.         }

  45.         return result;
  46.     }
复制代码
  1. Question 2) Implement insert and delete in a tri-nary tree. A tri-nary tree is much like a binary
  2. tree but with three child nodes for each parent instead of two -- with the left node being values
  3. less than the parent, the right node values greater than the parent, and the middle nodes values
  4. equal to the parent.
  5. For example, suppose I added the following nodes to the tree in this order: 5, 4, 9, 5, 7, 2, 2.
  6. The resulting tree would look like this:
  7.     5
  8.   / | \
  9. 4  5  9
  10. /     /
  11. 2   7
  12. |
  13. 2
复制代码
[        DISCUZ_CODE
您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限查看其他获取积分的方式
Unlock interview details and practice with AI
Curated Interview Questions from Top Companies
到右下角(只能向右或者向下),每个格子有硬币,求最后能拿到的最大硬币值



评分

参与人数 7大米 +101 收起 理由
Shelly0507 + 5 给你点个赞!
sophiacy + 5 给你点个赞!
wzhang80 + 2 很有用的信息!
破烂CC + 2 给你点个赞!
pnoxoxo + 2 感谢分享!

查看全部评分


上一篇:Nationwide电面
下一篇:Snapchat OA 附解答
推荐
coolgod 2016-10-10 12:53:49 | 只看该作者
全局:
朋友,你这个delete有问题,根本没有删掉啊。
root = root.left,这一句。你只是把root这个引用本身的指向改变了,但root的parent还是指向root原来的内存地址。道理和下面的示例代码一样:
  1. public class NodeDeletion {
  2.         public static void main(String[] args) {
  3.                 Node root = new Node(1);
  4.                 Node left = new Node(0);
  5.                 Node right = new Node(2);
  6.                 root.left = left;
  7.                 root.right = right;
  8.                 left = null; // 并没有删掉,root.left还是指向原来的位置
  9.                 System.out.println(root.left.val);               
  10.         }
  11.        
  12.         static class Node {
  13.                 public int val = 0;
  14.                 public Node left;
  15.                 public Node right;
  16.                 Node(int val){
  17.                         this.val = val;
  18.                 }
  19.         }
  20. }
复制代码

你可以把你的代码放到IDE跑一遍,是通不过一些测试的。

补充内容 (2016-10-10 13:07):
不好意思,是我看错了,是要把替换的node返回的。
回复

使用道具 举报

推荐
 楼主| bearcat001 2016-10-26 05:42:32 | 只看该作者
全局:
kradnangel 发表于 2016-10-26 04:08
请问楼主能介绍一下内推人给我吗?我也想内推.... 谢谢!

我是在LinkedIn上面找的学长,你可以在LinkedIn上面找一下你们学校的,或者不认识的人也可以说说自己情况问一下是否愿意内推
回复

使用道具 举报

推荐
 楼主| bearcat001 2016-10-6 07:41:39 | 只看该作者
全局:
owensharon 发表于 2016-10-6 06:46
还有啊,楼主你的stringToLong的那个代码,似乎合法输出一直都是正数呀,虽然记录了sign,但是没有用起来呢

0 - 0 你这么一说,好像是... 奇怪,我好像没有在最后处理
回复

使用道具 举报

🔗
janice0613 2016-9-30 02:13:15 | 只看该作者
全局:
楼主,你的zillow内推了多收到的确认邮件呢?
回复

使用道具 举报

🔗
 楼主| bearcat001 2016-9-30 02:25:06 | 只看该作者
全局:
janice0613 发表于 2016-9-30 02:13
楼主,你的zillow内推了多收到的确认邮件呢?

我记得没太久,应该一周?
回复

使用道具 举报

🔗
忆梦前尘 2016-9-30 03:41:41 | 只看该作者
全局:
求问LZ投的是zillow什么职位。。。。翻了一下官网university的分类是空的。。
回复

使用道具 举报

🔗
 楼主| bearcat001 2016-9-30 03:47:52 | 只看该作者
全局:
忆梦前尘 发表于 2016-9-30 03:41
求问LZ投的是zillow什么职位。。。。翻了一下官网university的分类是空的。。

Software Development Engineer New Grad
是内推人帮我选的~
回复

使用道具 举报

🔗
忆梦前尘 2016-9-30 04:46:43 | 只看该作者
全局:
bearcat001 发表于 2016-9-29 11:47
Software Development Engineer New Grad
是内推人帮我选的~

完蛋了。。。。现在已经没有了。。。
回复

使用道具 举报

🔗
wantanintern 2016-10-1 01:54:36 | 只看该作者
全局:
谢谢lz分享,我下下周也要店面了,求问lz有看地里面经吗?我搜到的都是去年前年的。。
回复

使用道具 举报

🔗
 楼主| bearcat001 2016-10-1 02:28:56 | 只看该作者
全局:
wantanintern 发表于 2016-10-1 01:54
谢谢lz分享,我下下周也要店面了,求问lz有看地里面经吗?我搜到的都是去年前年的。。

我没找到太多面筋~ 我就在刷leetcode
回复

使用道具 举报

🔗
wantanintern 2016-10-1 04:11:19 | 只看该作者
全局:
可以再问一下是谁面的你吗?谢谢!
回复

使用道具 举报

🔗
liguanzhu92 2016-10-1 04:26:32 | 只看该作者
全局:
表示翻遍了zillow 真的没有看到Software Development Engineer New Grad 。。。
回复

使用道具 举报

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

本版积分规则

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