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

TripAdvisor online test

全局:

2014(1-3月) 码农类General 硕士 全职@TripAdvisor - 网上海投 - 在线笔试  | | Pass |

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

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

x
40 分钟写两道算法题,还是有点恶心,Codility代码区域这个好像不能复制粘贴,同时这些题目题干都比较长,理解题意都要几分钟,如果不提前准备的话,很危险

1.
A stack machine is a simple system that performs arithmetic operations on an input string of numbers and operators. It contains a stack that can store an arbitrary number of 12-bit unsigned integers. Initially the stack is empty. The machine processes a string of characters in the following way:
the characters of the string are processed one by one;
if the current character is a digit ('0'-'9'), the machine pushes the value of that digit onto its stack;
if the current character is '+', the machine pops the two topmost values from its stack, adds them and pushes the result onto the stack;
if the current character is '*', the machine pops the two topmost values from its stack, multiplies them and pushes the result onto the stack;
after the machine has processed the whole string it returns the topmost value of its stack as the result;
the machine reports an error if any operation it performs
您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限查看其他获取积分的方式
Unlock interview details and practice with AI
Curated Interview Questions from Top Companies
its magnitude poles. The function should return −1 if array A does not have a magnitude pole.
For example, given array A consisting of ten elements such that:
  A[0] = 4  
  A[1] = 2  
  A[2] = 2
  A[3] = 3  
  A[4] = 1  
  A[5] = 4
  A[6] = 7  
  A[7] = 8  
  A[8] = 6
  A[9] = 9
the function may return 5 or 9, as explained above.
Assume that:
N is an integer within the range [0..100,000];
each element of array A is an integer within the range [−2147483648..2147483647].
Complexity:
expected worst-case time complexity is O(N);
expected worst-case space complexity is O(N), beyond input storage (not counting the storage required for input arguments).
Elements of input arrays can be modified.




评分

参与人数 4大米 +19 收起 理由
一点点飞 + 3 感谢分享!
weiqitsai + 3 感谢分享!
大屁股妖 + 3 谢谢lz!
kang1415926 + 10 感谢分享!

查看全部评分


上一篇:Medallia Online Test
下一篇:Twitter Online Test
🔗
cqx83 2014-2-16 12:40:53 | 只看该作者
全局:
投了tripadvisor一直没给我回信。。。
回复

使用道具 举报

🔗
nealaws 2014-2-16 13:19:57 | 只看该作者
全局:
第一个leetcode原题 第二题从头到尾扫描记录从头到当前点前的最大值 从尾到头扫描记录从尾到当前点后的最大值 跟原array比较 如果原值大于等于两个数组的值 即是结果
回复

使用道具 举报

🔗
 楼主| sumingche 2014-2-18 01:18:01 | 只看该作者
全局:
cqx83 发表于 2014-2-15 23:40
投了tripadvisor一直没给我回信。。。

我是找人refer的,觉得这个公司不太容易给面试~
回复

使用道具 举报

🔗
一点点飞 2014-4-16 12:33:30 | 只看该作者
全局:
感谢楼主!看了题目提前准备了一下!刚考完,就是这俩题。等结果吧!谢谢啦!!
回复

使用道具 举报

🔗
 楼主| sumingche 2014-4-17 02:07:56 | 只看该作者
全局:
一点点飞 发表于 2014-4-15 23:33
感谢楼主!看了题目提前准备了一下!刚考完,就是这俩题。等结果吧!谢谢啦!!

不客气哈,给加点分吧~
回复

使用道具 举报

🔗
heart_shine 2014-8-8 09:56:11 | 只看该作者
全局:
谢谢楼主分享上面的问题,正在思考ing~~~
回复

使用道具 举报

🔗
heart_shine 2014-8-9 01:15:56 | 只看该作者
全局:
lhn9021 发表于 2014-2-16 13:19
第一个leetcode原题 第二题从头到尾扫描记录从头到当前点前的最大值 从尾到头扫描记录从尾到当前点后的最大 ...

我没读懂你说的第二题的解法,不过我想的是,新建两个boolean array, 一个记录从左到当前值的最大值(max),如果 max <= A[i],  为true,反之 false; 另一个记录从右边起到当前值的最小值(min),如果min >= A[i], 为true, 反之false;   如果同一个i 都为true,则返回;

有更好的方法么?
回复

使用道具 举报

🔗
genius19 2014-10-15 10:13:17 | 只看该作者
全局:
请问它有规定用什么语言写吗?
回复

使用道具 举报

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

本版积分规则

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