📣 独立日限时特惠: VIP通行证立减$68
楼主: wrj5518
跳转到指定楼层
上一主题 下一主题
收起左侧

[CareerCup] 【第三轮】6.16-6.22 CareerCup 1.1

 
🔗
chouclee 2014-6-16 12:12:32 | 只看该作者
全局:
【解题思路】 用boolean[] 模拟Hashtable,但只能对ASCII有效,unicode可以使用Hashtable
【时间复杂度】O(n)
【空间复杂度】O(1)
【gist link】普通版:https://gist.github.com/chouclee/5880c7fdf95bf593c395
Hashtable版 https://gist.github.com/chouclee/837102ddb0273f428cb5

评分

参与人数 1大米 +7 收起 理由
wrj5518 + 7

查看全部评分

回复

使用道具 举报

🔗
jason51122 2014-6-16 12:34:50 | 只看该作者
全局:
本帖最后由 jason51122 于 2014-6-16 12:43 编辑

【解题思路】Assume the input is an ASCII string. Create a boolean array to keep record all states. Traverse the string and return false if any char has seen before. Return true after the traversal.
【时间复杂度】O(n)
【空间复杂度】O(1)
【gist link】https://gist.github.com/jason51122/cad80336bdbbe7ecd02d

评分

参与人数 1大米 +7 收起 理由
wrj5518 + 7

查看全部评分

回复

使用道具 举报

🔗
jing0328 2014-6-16 13:37:34 | 只看该作者
全局:
本帖最后由 jing0328 于 2014-6-16 14:04 编辑

【解题思路】create a boolean array of length 256 and travese the string to set true/false in the correspoding spot (according to ASCII table), if some spot has already been set to true, then duplicate char exists.
【时间复杂度】O(n)
【空间复杂度】O(1)
【gist link】https://gist.github.com/startupjing/dfd6a05aa122d53afb05
---------------OPTional,如果觉得test case比较好,欢迎写出来分享----------------------
【test case】my solution includes a user-interaction part where user can enter the input string and program outputs the result (true/false)

评分

参与人数 1大米 +7 收起 理由
wrj5518 + 7

查看全部评分

回复

使用道具 举报

🔗
jyh橘子 2014-6-16 14:31:03 | 只看该作者
全局:
【解题思路】假设是ascii字符 共256个  用长度为256的Boolean数组表示某字符是否出现过
【时间复杂度】O(n)
【空间复杂度】O(1)
【gist link】  https://gist.github.com/jyhjuzi/1f526165a8a54148bde4

评分

参与人数 1大米 +7 收起 理由
wrj5518 + 7

查看全部评分

回复

使用道具 举报

🔗
林微熙 2014-6-16 14:42:56 | 只看该作者
全局:
【解题思路】Assume the input is an ASCII string(256). Create a boolean array to keep record all states. Traverse the string and return false if any char has seen before. Return true after the traversal.楼上的和我想的差不多,这好像也是标准常用方法。初刷题。多观摩大家的方案吧
【时间复杂度】O(n)
【空间复杂度】O(1)
【gist link】https://gist.github.com/hilda8519/69fcc6db1db7efb8e107
【test case】

评分

参与人数 1大米 +7 收起 理由
wrj5518 + 7

查看全部评分

回复

使用道具 举报

🔗
兰橘清檬 2014-6-16 15:53:08 | 只看该作者
全局:
immortaliqi 发表于 2014-6-16 00:36
【解题思路】
  • 用一个数组储存 每次储存新字符的时候检查数组 如果存在直接return
  • 如果字符库只限 ...

  • 木有代码,还真是拖延症啊。。。

    评分

    参与人数 1大米 +7 收起 理由
    wrj5518 + 7

    查看全部评分

    回复

    使用道具 举报

    🔗
    兰橘清檬 2014-6-16 16:17:57 | 只看该作者
    全局:
    【解题思路】设字符集为ascii(大小256),一个大小为256的 boolean 数组,出现一次后字符相应位置为 true,否则为 false
    【时间复杂度】O(n)
    【空间复杂度】O(n)
    【gist link】https://gist.github.com/JoyceeLee/8118612ec2b571730f30
    ---------------OPTional,如果觉得test case比较好,欢迎写出来分享----------------------
    【test case】

    评分

    参与人数 1大米 +7 收起 理由
    wrj5518 + 7

    查看全部评分

    回复

    使用道具 举报

    🔗
    MrAcc 2014-6-16 16:25:59 | 只看该作者
    全局:
    【解题思路】
    可以使用其他数据结构的话,采用Set,相同字符的话覆盖,最后比较总数
    不可使用其他数据结构的话,采用一个大小为256的数组,统计每个字符的出现次数
    【时间复杂度】
      O(n)
    【空间复杂度】
      O(1)
    【gist link】
    https://gist.github.com/MrCQ/6ec6ac7c5b7992eef6a5

    评分

    参与人数 1大米 +7 收起 理由
    wrj5518 + 7

    查看全部评分

    回复

    使用道具 举报

    🔗
    bitcpf 2014-6-16 23:11:12 | 只看该作者
    全局:
    本帖最后由 bitcpf 于 2014-6-16 09:13 编辑

    【解题思路】
    Assume all characters are ASCII, then create a bool array with 256 member all false
    Traverse all characters in the String
    If the ASCII value is not true in the array, mark the ASCII array as ture
    Else return false
    【时间复杂度】
      O(n)
    【空间复杂度】  boolen array is a constant 256
      O(1)
    【gist link】
    https://gist.github.com/bitcpf/404d4d71e6c40a92fc2f

    评分

    参与人数 1大米 +7 收起 理由
    wrj5518 + 7

    查看全部评分

    回复

    使用道具 举报

    🔗
    锦木千束 2014-6-16 23:39:27 | 只看该作者
    全局:
    本帖最后由 锦木千束 于 2014-6-17 07:39 编辑

    【解题思路】好像和前面好几个人都一样,开一个256的bool数组每个代表对应的ascii是否出现过,出现一样的就返回false,第一次写java,真是蠢哭了
    【时间复杂度】不会算啊,我现在学好吗
    【空间复杂度】。。。。
    【gist link】https://gist.github.com/weazord/9335e136f52a5850f1ef

    update
    【时间复杂度】O(n)
    【空间复杂度】O(1)
    应该没错吧。。。再看会书

    评分

    参与人数 1大米 +7 收起 理由
    wrj5518 + 7

    查看全部评分

    回复

    使用道具 举报

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

    本版积分规则

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