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

丢盒子 技术电面

抢楼 抢楼 本帖为抢楼帖,总积分大于100可以抢楼  
全局:

2019(4-6月) 码农类General 硕士 全职@dropbox - 网上海投 - 技术电面  | | Fail | 其他

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

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

x
Dropbox是唯一自己投的一家, 题目是大家 都提到的Nasa的 那个section对应存图片. 我觉得他们家除了coding 还有很多其他的问题也很重要.关键有几个问题啊:
1. 图片怎么存储, 我看面经 有人提到size
您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限 或 查看其他获取积分的方式
Unlock interview details and practice with AI
Curated Interview Questions from Top Companies
大家如果失败了,不要气馁, 加油努力,向前看吧.
我可以把我的代码贴上来 给大家参考吧.

  1. import java.awt.*;
  2. import java.util.HashMap;
  3. import java.util.Map;

  4. public class PanaromaDropBox {
  5.     private class Part {
  6.         int column;
  7.         int row;
  8.         String path;
  9.         Part next;

  10.         public Part(int row, int column) {
  11.             this.row = row;
  12.             this.column = column;
  13.             this.path = "";
  14.             this.next = null;
  15.         }

  16.         public Part(int row, int column, String path) {
  17.             this.row = row;
  18.             this.column = column;
  19.             this.path = path;
  20.             this.next = null;
  21.         }
  22.     }

  23.     Map<Part, Part> keyPrev;
  24.     Part head;
  25.     Part tail;
  26.     int size;
  27.     int capacity;

  28.     int nrows;
  29.     int ncolumns;
  30.     String basePath;
  31.     //Map<Part, String> buffer; //(String is the path of the image)

  32.     public PanaromaDropBox(int capacity, int numOfRows, int numOfColumns, String basePath) {
  33.         this.capacity = capacity;
  34.         this.size = 0;
  35.         this.head = new Part(-1, -1);
  36.         this.tail = head;
  37.         this.keyPrev = new HashMap<>();

  38.         this.nrows = numOfRows;
  39.         this.ncolumns = numOfColumns;
  40.         this.basePath = basePath;
  41.         //this.buffer = new HashMap<>();
  42.     }

  43.     private void moveToBack(Part prev) {
  44.         Part current = prev.next;
  45.         prev.next = current.next;
  46.         keyPrev.put(current.next, prev);
  47.         tail.next = current;
  48.         keyPrev.put(current, tail);
  49.         tail = current;
  50.         current.next = null;
  51.     }

  52.     public void update(int i, int j, Image image) {
  53.         Part current = null;
  54.         for (Part part : keyPrev.keySet()) {
  55.             if (part.row == i && part.column == j) {
  56.                 current = part;
  57.                 break;
  58.             }
  59.         }

  60.         String imagePath = basePath + hash(image);
  61.         if (current != null) {
  62.             Part prev = keyPrev.get(current);
  63.             if (prev.next != tail) {
  64.                 moveToBack(prev);
  65.                 tail.path = imagePath;
  66.                 return;
  67.             }
  68.             tail.path = imagePath;
  69.             return;
  70.         }

  71.         if (size < capacity) {
  72.             current = new Part(i, j, imagePath);
  73.             tail.next = current;
  74.             keyPrev.put(current, tail);
  75.             tail = current;
  76.             size++;
  77.             return;
  78.         }

  79.         current = new Part(i, j, imagePath);
  80.         tail.next = current;
  81.         keyPrev.put(current, tail);
  82.         tail = current;

  83.         keyPrev.remove(head.next);
  84.         head.next = head.next.next;
  85.         keyPrev.put(head.next, head);

  86. //        String imagePath = basePath + hash(image);
  87. //        Part current = null;
  88. //        for (Part part : buffer.keySet()) {
  89. //            if (part.row == i && part.column == j) {
  90. //                current = part;
  91. //                break;
  92. //            }
  93. //        }
  94. //        if (current == null) {
  95. //            current = new Part(i, j);
  96. //        }
  97. //
  98. //        buffer.put(current, imagePath);
  99.     }
  100.     public Image fetch(int i, int j) {
  101.         Part result = null;
  102.         for (Part part : keyPrev.keySet()/*buffer.keySet()*/) {
  103.             if (part.row == i && part.column == j) {
  104.                 result = part;
  105.                 break;
  106.             }
  107.         }

  108.         if (result != null) {
  109.             String path = keyPrev.get(result).path;/*buffer.get(result)*/
  110.             read_file(path);
  111.             return null;
  112.         }
  113.         return null;
  114.     }

  115.     public int[] getOldestImage() {
  116.         int[] result = new int[]{head.row, head.column};
  117.         return result;
  118.     }

  119.     /* return unique string given image */
  120.     private String hash(Image image) {
  121.         return "";
  122.     }

  123.     /* 假设如果已经给了api用来read/write imge
  124.     *  这个我有点记不清了 but 这个不重要就就是一些I/O api 他会给出
  125.     */
  126.     private void read_file(String pathOfImage) {

  127.         //return Image;
  128.     }

  129.     private void save_file(Image image){

  130.     }
  131. }
复制代码


评分

参与人数 5大米 +36 收起 理由
nyjahchill + 3 很有用的信息!
guwenjun2007 + 1 给你点个赞!
江城渔翁 + 1 给你点个赞!
CodingAnna + 1 赞一个
匿名用户-YUNPM + 30

查看全部评分


上一篇:易呗现场
下一篇:亚麻电面+onsite
全局:
可以问下楼主size hash是什么吗?谢谢!
回复

使用道具 举报

🔗
江城渔翁 2019-7-14 04:09:41 | 只看该作者
全局:
同问楼主size hash是什么, 另外被comment掉的 code是follow up还是什么?
回复

使用道具 举报

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

本版积分规则

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