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

新鲜出炉amazon实习面经

全局:

2016(1-3月) 码农类General 硕士 实习@amazon - 内推 - 技术电面  | | Other | 应届毕业生

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

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

x
约的早上9点面试,9点01分收到来自西雅图的电话,口音标准(应该不是印度人,但貌似也不是白人)。上来先问了之前做了哪些project,用什么framework。我说我一般用C++,他表示他这些年都是写JAVA,C++忘得差不多了。我本着随便聊的态度说哦我之前写Android有用过JAVA但是不太熟练,然后不造为
您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限查看其他获取积分的方式
Unlock interview details and practice with AI
Curated Interview Questions from Top Companies
...
啊希望能有offerTAT,找实习真是烦死了TAT。


补充内容 (2016-1-27 07:35):
TAT才过了一天已经收到拒信了。。

上一篇:Fidessa 最新OA 换了完全不一样的题目
下一篇:亚麻oa1 oa2
全局:
不懂是不是这个意思?欢迎大家讨论。。。

class time {
    int year;
    int month;
    int day;
    public time (int year, int month, int day) {
        this.year = year;
        this.month = month;
        this.day = day;
    }
}
public class Transcation {
    private int id;
    private time date;
    public Transcation(int id, time date) {
        this.id = id;
        this.date = date;
    }

    public Transcation find (List<Transcation> list) {
        Collections.sort(list, new Comparator<Transcation>() {
            @Override
            public int compare(Transcation o1, Transcation o2) {
                if (o1.date.year != o2.date.year) return o1.date.year - o2.date.year;
                else if (o1.date.month != o2.date.month) return o1.date.month - o2.date.month;
                else return o1.date.day - o2.date.day;
            }
        });
        HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();//id -> index
        for (int i = 0; i < list.size(); i++) {
            if (!map.containsKey(list.get(i).id)) map.put(list.get(i).id, i);
            else map.put(list.get(i).id, -1);
        }

        for (Transcation t : list) {
            if (map.get(t.id) != -1)
                return list.get(map.get(t.id));
        }
        return null;
    }

    public static void main(String[] args) {
        Transcation t1 = new Transcation(1, new time(2015, 1, 2));
        Transcation t2 = new Transcation(1, new time(2013, 2, 3));
        Transcation t3 = new Transcation(2, new time(2015, 1, 1));
        Transcation t4 = new Transcation(3, new time(2015, 2, 1));
        List<Transcation> list = new ArrayList<Transcation>(Arrays.asList(t1, t2, t3, t4));
        Transcation res = t1.find(list);

        System.out.println("id: " + res.id);
        System.out.println("time: " + res.date.year + "/" + res.date.month + "/" + res.date.day);
    }
}
回复

使用道具 举报

全局:
喜马拉雅疯子 发表于 2016-2-2 03:15
我觉得楼楼上的方法是对滴。。如果是big scale的data,用external sorting排序, hashtable就改用 trie存吧 ...

我说一个想法,用hash map来map id 和记录,遍历的时候如果发现有多于一条记录就将key置为null,然后用keyset来遍历整个table,找出对应最小时间的那个key。这样是O(n) time 的解法
回复

使用道具 举报

🔗
ljdsoft 2016-1-26 08:41:39 | 只看该作者
全局:
是不是先根据id放到一个hashmap里面,然后再遍历一遍这个hashmap找到最早时间且只有一个交易的id?
回复

使用道具 举报

🔗
 楼主| lycheebuchi 2016-1-26 09:16:03 | 只看该作者
全局:
ljdsoft 发表于 2016-1-26 08:41
是不是先根据id放到一个hashmap里面,然后再遍历一遍这个hashmap找到最早时间且只有一个交易的id?

我是先按date排序然后再按id排,其实觉得有问题但是面试官说sounds work...我也就假装是对的了
回复

使用道具 举报

🔗
tong-1324 2016-1-26 11:00:36 | 只看该作者
全局:
恭喜恭喜!offer在路上!
回复

使用道具 举报

🔗
mchzh 2016-1-26 11:43:40 | 只看该作者
全局:
lycheebuchi 发表于 2016-1-26 09:16
我是先按date排序然后再按id排,其实觉得有问题但是面试官说sounds work...我也就假装是对的了

是不是跟海量数据的处理相关了
回复

使用道具 举报

🔗
lsyzju 2016-2-1 00:38:02 | 只看该作者
全局:
楼主可以详细说下这道题还有什么要求吗 我感觉你的做法没什么问题啊
可能是我没有明白题的意思
谢谢
回复

使用道具 举报

🔗
aangel 2016-2-1 05:37:38 | 只看该作者
全局:
letsdoit666 发表于 2016-2-1 05:00
不懂是不是这个意思?欢迎大家讨论。。。

class time {

我也觉得这个是对的,还有别的tricky的地方吗
回复

使用道具 举报

全局:
我觉得楼楼上的方法是对滴。。如果是big scale的data,用external sorting排序, hashtable就改用 trie存吧。但是方法应该是这样做没错
回复

使用道具 举报

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

本版积分规则

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