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

[CareerCup] [第二轮] 2/18-2/24 CareerCup 1.1

全局:
czhoume 发表于 2013-2-18 06:03
I think no more data structure allowed need to be more specified. I will ask if I am in an interview ...

Nice job, I would do the same way if I hadn't seen the solution..
回复

使用道具 举报

🔗
ac/dc 2013-2-18 13:46:07 | 只看该作者
全局:
1. Hashtable
2. Sort & Check

https://gist.github.com/JasonGitHub/4975301
回复

使用道具 举报

全局:
paradox 发表于 2013-2-18 03:12
I think you need improve your code style. Your python code looks very messy.
Here is mine, you ca ...

For the ifDuplicate1, you can check the value every time before adding 1 and return false if it is already 1. I think there is no need to write another for loop to check the charCount values.

By the way, I don't see what is the additional data structure in ifDuplicate1.

The code is neat. ;)

点评

LOL, exactly. thanks for the comments. I consider the map array as additional data strcutre  发表于 2013-2-19 02:14
回复

使用道具 举报

🔗
liangkaile 2013-2-18 14:58:43 | 只看该作者
全局:
Language: C
Algorithm: Nested loop, compare the i-th with the rest

https://gist.github.com/liangkaile/4975514
回复

使用道具 举报

🔗
liangkaile 2013-2-18 15:11:18 | 只看该作者
全局:
gist link:
回复

使用道具 举报

🔗
jwzxgo 2013-2-18 18:06:55 | 只看该作者
全局:
Java solutions: https://github.com/wangtz/Career ... dStrings/Ch1Q1.java

n: input.length
k: amount of different unique characters

for time and storage complexity:
* hash o(n) o(k)
* simple hash only works for 'a' to 'z' can be extended o(n) o(k)
* bit operation only works for 'a' to 'z' can be extended to UNICODE using multiple ints o(n) o(k/64)
* sort before check o(nlogn) o(1)
* brute force nested loop compare o(n^2) o(1)
回复

使用道具 举报

🔗
yukainuo23 2013-2-18 18:45:26 | 只看该作者
全局:
https://gist.github.com/anonymous/4976549
因为以前做过careercup的一部分题,所以思路大概是差不多的!但是难免有错漏和效率方面的问题,请多多指教!
回复

使用道具 举报

🔗
jerrysun 2013-2-18 19:34:36 | 只看该作者
全局:
https://gist.github.com/JerrySun363/0c7fb3b4d9c54aa41171

其实不是很清楚能用什么样的API
第一个用一个HashSet,第二个用了排序+比较
回复

使用道具 举报

🔗
sunnyroom 2013-2-18 22:21:47 | 只看该作者
全局:
用了最笨的办法,每个字符循环比较。时间,空间复杂度什么的,还不知道怎么算,明天学习一下,然后看一下大家的做法
https://gist.github.com/sunxw/4975738
回复

使用道具 举报

🔗
jerrysun 2013-2-19 00:35:41 | 只看该作者
全局:
yukainuo23 发表于 2013-2-18 18:45
https://gist.github.com/anonymous/4976549
因为以前做过careercup的一部分题,所以思路大概是差不多的! ...

看了一会才明白,ls是把 unique characters 当作输入并且放到bitmap里去的;
大概对题目的理解不一样吧... ...
回复

使用道具 举报

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

本版积分规则

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