查看: 8211| 回复: 5
跳转到指定楼层
上一主题 下一主题
收起左侧

[实习] Arrowstreet Capital hackerrank

全局:

2019(10-12月)-CS本科+fresh grad 无实习或全职 | 网上海投| 金工类实习@Arrowstreet Capital

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

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

x
一共8题,其中3题选择,剩下的题包括shortest substring containing all chars,还有几道比较简单的记不起来了,印象比较深的是最后一道我没写出来,题目放这里了大家帮我想想该怎么做

input two array arrival and departure,arrival[i] and departure[i] are i th person's arrival date and departure date respectively. Each day you can only meet one person. Find the max number of purple you can meet before they leave.. check 1point3acres for more.

EX: arrival = {1,2,2,3}, departure = {2,2,3,4}, then return 4 because you can meet person0 on day1, person1 on day2, person2 on day3, person3 on day4. However, if arrival = {2,2,2,3}, departure = {2,3,4,4} then return 3.

之前乍一看以为是经典的interval scheduling problem用greedy select earliest end time的,但这道题不一样那么做是不对的,想问问大家有什么想法吗?

评分

参与人数 1大米 +1 收起 理由
Ccqw12 + 1 给你点个赞!

查看全部评分


上一篇:Snowflake实习 VS Oracle全职 求比较
下一篇:大家是如何面对身份衔接上的不确定性的
推荐
菠萝QPQC 2022-10-12 10:54:51 | 只看该作者
全局:
我搞了一个解法感觉是对的: sort by earliest start time, if tie then sort by earliest end time. 然后时间轴从左到右过一遍,优先把时间点分配给前面的interval.
BTW, 楼主面的是software engineer还是quantitative developer呀
回复

使用道具 举报

🔗
小熊牛牛 2019-12-4 08:45:09 | 只看该作者
全局:
dfs 就好了
def f(arrival, departure):
    visited = set()
    f.res = 0
    def dfs(idx, path):. ----
        f.res = max(f.res, path)
        for i in range(idx, len(arrival)):
            for j in range(arrival[i], departure[i] + 1):
                if not j in visited:
                    visited.add(j)
                    dfs(idx + 1, path + 1). 1point 3 acres
                    visited.remove(j)
    dfs(0, 0)
    return f.res

print(f([2,2,2,3], [2,3,4,4]))
回复

使用道具 举报

🔗
jassimons 2019-12-12 06:00:55 | 只看该作者
全局:
请问楼主有后续了吗?感谢~
回复

使用道具 举报

🔗
4552dosen 2020-12-19 16:02:23 | 只看该作者
全局:
小熊牛牛 发表于 2019-12-4 08:45
dfs 就好了
def f(arrival, departure):
    visited = set()

如果arrival = [1,2,2,3], departure = [4,2,2,5] 答案好像就不太对了
回复

使用道具 举报

全局:
Greedy吧?
回复

使用道具 举报

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

本版积分规则

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