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

新鲜出炉的Palantir超冷门的电面

全局:

2015(1-3月) 码农类General 本科 实习@Palantir - 网上海投 - 技术电面  | | Fail |

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

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

x
分享一个周三刚刚完成的Palantir超冷门的电面。为啥冷门呢?因为它全是debug改错题.....为什么和网上的面经完全不一样的画风啊摔!不过不难是真的,可能看我是大三所以手下留情吧2333
下面是整套题的代码,给了几个function以及comments,让改最后一个function的错误,both correctness and performance

=========================================================================
  1. class Result {
  2. public:
  3.                 /**     
  4.                 * Gets the result's timestamp. Results with lower timestamps are loaded
  5.              * before results with higher timestamps. Timestamps are guaranteed to be
  6.              * non-negative, and different results have distinct timestamps.
  7.              */
  8.                 long getTimestamp() const;
  9.                 /**     
  10.                 * Prints a textual representation of this result.
  11.              */
  12.                 std::string getDescription() const;

  13.         // Other methods not important for this problem
  14.                
  15. };

  16. /**
  17. * Return type used for page-based iteration. See the comment on loadResultsPage
  18. * for the precise meaning of the fields.
  19. */
  20. struct ResultsPage {
  21.         std::vector<Result> resultList;
  22.         bool hasMoreResults;
  23. };

  24. /**
  25. * Returns the next pageSize results that have a timestamp greater than or equal
  26. * to startTime. The results are guaranteed to be ordered by timestamp
  27. * (increasing).
  28. *
  29. * If there are at least pageSize results available, the resultList contains the
  30. * next pageSize results. If there are fewer than pageSize results available,
  31. * resultList contains all remaining results. hasMoreResults in the ResultsPage
  32. * is true if and only if there are more results to load after the ones in
  33. * resultList.
  34. *
  35. * The results are loaded from the database as a batch.
  36. */
  37. ResultsPage loadResultsPage(long startTime, int pageSize);

  38. /*******************************************************************************
  39. * Instructions: Find as many errors as possible in the code below. Make a copy
  40. * of the function and change the code to be correct.
  41. *
  42. * You should be looking for correctness and performance issues. You may assume
  43. * that the code correctly compiles.
  44. ******************************************************************************/

  45. /**
  46. * This method should print the contents of all results to the console.
  47. */
  48. void printAllResults() {
  49.     int pageSize = 100;
  50.     long currentTimestamp = 0;
  51.     while (loadResultsPage(currentTimestamp, pageSize).hasMoreResults) {
  52.         std::vector<Result> resultList = loadResultsPage(currentTimestamp, pageSize).resultList;
  53.         for (int i = 0; i < pageSize; i++) {
  54.             Result result = resultList[i];
  55.             cout << result.getDescription() << endl;
  56.         }
  57.         Result lastResult = resultList[resultList.size()];
  58.         currentTimestamp = lastResult.getTimestamp();
  59.     }
  60. }

复制代码
=========================================================================
我找出了如下改进:
redundant calls to loadResultPage(), could be reduced to once per while-loop iteration;
最后一个iteration后应该再读一次被遗漏的resultPage, 然pageSize parameter应改成list.size();
您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限查看其他获取积分的方式
Unlock interview details and practice with AI
Curated Interview Questions from Top Companies
r:rgb(247, 247, 247)">嗯,然后照例让我问问题,然后我说表示这个题很有趣,因为完全没碰到过这种形式,然后recruiter非常高冷的有嘲讽的语调说其他的面试问题都是algorithm对吧?立刻脑补到小哥一脸傲娇的“我们偏偏要与众不同”..然后周四被秒拒,跪的干脆利落~BTW,这个recruiter全程非常安静,也完全不要求我和他沟通交流,甚至和我说“只要你觉得舒服,埋头改就行,不用告诉我想法”......然后电话全程安静的都听不见呼吸,我几次以为他掉线了.....好不适应这种方式,话唠的我(实力不够)果然比较喜欢不停说想法少写代码的面试呐~就酱,希望对大家有帮助~

评分

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

查看全部评分


上一篇:Amazon 3-18 Video 面经
下一篇:Epic OA面经及总结
🔗
 楼主| jmjemi327 2015-3-22 05:38:27 | 只看该作者
全局:
咦Part 2的第二个function是被过滤了么......再贴一遍:

ResultPage getVisiblePage(long startTime, int pageSize){
        int size = pageSize;
        vector<ResultsPage> unfiltered = loadResultsPage(startTime, pageSize);
        vector<> filtered;
        for each result in unfiltered.resultList:
                if isResultVisible(result):
                        filtered.push_back(result);
        return filtered;
}
回复

使用道具 举报

🔗
Monster_SJTU 2015-3-24 02:31:43 | 只看该作者
全局:
LZ的recuiter是哪位呀~?
回复

使用道具 举报

🔗
 楼主| jmjemi327 2015-3-24 03:03:05 | 只看该作者
全局:
Monster_SJTU 发表于 2015-3-24 02:31
LZ的recuiter是哪位呀~?

他说话说太快没听清,只知道first name是David
回复

使用道具 举报

🔗
Monster_SJTU 2015-3-24 03:23:14 | 只看该作者
全局:
jmjemi327 发表于 2015-3-24 03:03
他说话说太快没听清,只知道first name是David

嗯嗯,谢谢~
回复

使用道具 举报

🔗
xyh99999 2015-3-24 03:26:52 | 只看该作者
全局:
jmjemi327 发表于 2015-3-24 03:03
他说话说太快没听清,只知道first name是David

llz原来你也在地里23333
回复

使用道具 举报

🔗
 楼主| jmjemi327 2015-3-24 10:32:12 | 只看该作者
全局:
xyh99999 发表于 2015-3-24 03:26
llz原来你也在地里23333

哈哈哈哈哈哈哈哈哈哈哈这也太巧了吧~~~
回复

使用道具 举报

🔗
offfer 2015-3-28 09:53:47 | 只看该作者
全局:
估计楼主是被分到面testing了.
回复

使用道具 举报

🔗
landuostorm 2015-3-28 13:39:15 | 只看该作者
全局:
这道我在Onsite遇到过现在直接拿来电面了。。
回复

使用道具 举报

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

本版积分规则

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