📣 黑五网一特惠|VIP一年通行证5折,蓝莓、Offer多多同步特惠
回复: 4
跳转到指定楼层
上一主题 下一主题
收起左侧

Rocket fuel OA以及店面

全局:

2014(10-12月) 码农类General 硕士 全职@Rocket fuel - 校园招聘会 - 技术电面  | | Fail |

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

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

x
先说OA,这个题目网上都有了。赛车手排序问题。我的做法第4个case过不去。但是还是拿到店面了。废话少说,直接上代码。我按照题目提示用buckets做的,buckets的大小会影响test case的通过率,我反复调也过不了第4个。
Mitbbs上还有大神用别的方法做的。


/* Enter your code here. Read input from STDIN. Print output to STDOUT */
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.*;

class Racer {
        int ID;
        long start;
        long end;
        int score;
        public Racer(int id,long start,long end){
                this.ID = id;
                this.start = start;
                this.end = end;
    }
    public void setscore(int score){
                this.score = score;
        }
        public int getscore(){
                return this.score;
        }
}

public class Solution {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        int n = Integer.parseInt(line);
        //arraylist save all racers records
        ArrayList<Racer> A = new ArrayList<Racer>();
        while ((line = br.readLine()) != null) {
           String[] k = line.split(" ");
                   Racer r1 = new Racer(Integer.parseInt(k[0]),Long.parseLong(k[1]),Long.parseLong(k[2]));
                   A.add(r1);
        }
        //sort the A array by start time decending
        Collections.sort(A, new Comparator<Racer>(){
                        public int compare(Racer r1,Racer r2){
                                if(r1.start > r2.start)
                    return -1;
                else
                    return 1;
                        }
                });
        //System.out.println("A size is "+A.size());
        //System.out.println(A.get(0).ID +" "+A.get(0).start );
        //use buckets, split and save all racers' data into buckets, then record the start time range of each bucket
        //sort each bucket by endtime
        ArrayList<ArrayList<Racer>> Buckets = new ArrayList<ArrayList<Racer>>();
        int buck_size = Math.max(1500,(int)Math.sqrt(n));
        HashMap<
您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限 或 查看其他获取积分的方式
Unlock interview details and practice with AI
Popular Interview Questions from Top Companies
long sentance
get all subsets from query vector
ex:
   1 1 0 1 1
   的subsets包括
   1 0 0 0 0
   1 1 0 0 0
.....

   search in hashmap2  


下面是代码,但是我没写完,比较乱,仅作参考
// process data, step 1
HashMap<String,Integer> map = new HashMap<String,Integer>();
int position = 0;
for(i : Ads) // i is single Ad, Ad.ID,  Ad.content
    for(k : i.content){
        if(!map.containsKey(k)){
            map.put(k,position);
            position++;
        }
    }
}



HashMap<Integer,vector[]> map1 = new HashMap<Integer,vector[]>();

for(i : Ads){
    int[] vector = new int[set.size()];
    for(k : i.content){
        vector[map.get(k)] = 1;
    }
    map1.put(i.ID,vector); //ID=1   vector= 1 1 0 0 ....
}

//step 2
int[] Q_vector = new int[set.size()];
for(i : query){
    Q_vector[map.get(i)] = 1;
}


//step 3  build map <vector,List<ID>>

HashMap<vector[],ArrayList<Integer>> map2 = new HashMap<vector[],ArrayList<Integer>>;
for(i : map1.keyValue()){
    if(!map2.containsKey(map1.get(i))
        map2.put(map1.get(i),new ArrayList
}


最后挂了。   





评分

参与人数 1大米 +5 收起 理由
ymqytw + 5 感谢分享!

查看全部评分


上一篇:Amazon Onsite面经
下一篇:EMC Software Dev 电话面试
🔗
chenwoo 2015-1-12 13:14:45 | 只看该作者
全局:
sorry to hear that.   你好,请教个问题哈。最近看面经都提到OA一词,什么是OA啊.我也想做做上面的题目练练,请问怎么在网上去找啊?thank you very much!
回复

使用道具 举报

🔗
xiaoxin213 2015-1-12 14:20:19 | 只看该作者
全局:
chenwoo 发表于 2015-1-12 13:14
sorry to hear that.   你好,请教个问题哈。最近看面经都提到OA一词,什么是OA啊.我也想做做上面的题目练 ...

是Online Assessment
回复

使用道具 举报

🔗
chenwoo 2015-1-14 07:08:40 | 只看该作者
全局:

Thanks, 请问怎么得到OA的机会啊?具体流程怎么做的啊?
回复

使用道具 举报

🔗
int_179 2015-1-14 09:29:15 | 只看该作者
全局:
我去 答的这么好都挂了 不科学啊
回复

使用道具 举报

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

本版积分规则

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