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

热乎乎的FB 店面

🔗
水浅王八多 2018-10-23 04:43:02 | 只看该作者
全局:
lindali2010 发表于 2018-10-20 03:08
Thanks for sharing and wish you can get offer asap.
My implementation:
        private static bool ...

想举个简单的例子质疑下第二题的思路:string[] s: "zz", "yy", "xx", char[] t: 'z', 'x','y'
我觉得问题在于我们其实需要scan一遍每一个string的每一个char才对。
不知道楼主或者层主是什么看法?
回复

使用道具 举报

🔗
 楼主| angerhang 2018-10-23 04:47:22 | 只看该作者
全局:
水浅王八多 发表于 2018-10-23 04:43
想举个简单的例子质疑下第二题的思路:string[] s: "zz", "yy", "xx", char[] t: 'z', 'x','y'
我觉得问 ...

是的每个char我们都需要scan才行
回复

使用道具 举报

🔗
 楼主| angerhang 2018-10-23 04:49:09 | 只看该作者
全局:
AiLiner 发表于 2018-10-22 01:29
第二题能给个栗子吗 是vector1里面的vector1的顺序吗 还是整个vector1的顺序

可以
比如说
vector I: ["aa", "bb", "cc"]
vector II: ['a', 'b', 'c']
return true

vector I: ["cc", "bb", "cc"]
vector II: ['a', 'b', 'c']
return false
回复

使用道具 举报

🔗
zy16373soup 2018-10-23 04:54:45 | 只看该作者
全局:
第二题很高频啊不过一直没太弄清楚 如果按照alien dictionary的思路,就找两个相邻word第一个不同的字母,然后看第一个字母的order是不是比第二个字母的order靠前就可以了?
回复

使用道具 举报

🔗
 楼主| angerhang 2018-10-23 04:57:41 | 只看该作者
全局:
zy16373soup 发表于 2018-10-23 04:54
第二题很高频啊不过一直没太弄清楚 如果按照alien dictionary的思路,就找两个相邻word第一个不同的字母, ...

是的。然后order的话用一个hash table存起来就好

评分

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

查看全部评分

回复

使用道具 举报

🔗
zy16373soup 2018-10-23 05:17:48 | 只看该作者
全局:
angerhang 发表于 2018-10-23 04:57
是的。然后order的话用一个hash table存起来就好

哇 那感觉直接hard变easy了 我还一直担心想简单了
回复

使用道具 举报

🔗
lindali2010 2018-10-23 07:05:23 | 只看该作者
全局:
水浅王八多 发表于 2018-10-23 04:43
想举个简单的例子质疑下第二题的思路:string[] s: "zz", "yy", "xx", char[] t: 'z', 'x','y'
我觉得问 ...

I think I misunderstand the question. Do you mean the question is to check if the whole string array is ordered by the char array? There isn't duplicated character in char[], right?
ex:
1. s[] : "aa", "bb", "cc", t[]: 'a', 'b', 'c', return true;
2. s[] : "ab", "ab", "cc", t[]: 'a',  'b', 'c' return false;
3. s[]: "aa", "bb", "aa", t[]: 'a', 'b', 'c' return false;

Wish I understand the question correctly this time. :)
回复

使用道具 举报

🔗
 楼主| angerhang 2018-10-23 07:15:54 | 只看该作者
全局:
lindali2010 发表于 2018-10-23 07:05
I think I misunderstand the question. Do you mean the question is to check if the whole string arr ...

Duplicates are allowed but it doesn't matter which one comes first if we have identical strings.
回复

使用道具 举报

🔗
lindali2010 2018-10-23 07:44:17 | 只看该作者
全局:
angerhang 发表于 2018-10-23 07:15
Duplicates are allowed but it doesn't matter which one comes first if we have identical strings.

so if s[] = "cbc",  "cbc", t[] = 'c', 'b', 'c', it will return true?
回复

使用道具 举报

🔗
水浅王八多 2018-10-23 08:17:55 | 只看该作者
全局:
lindali2010 发表于 2018-10-23 07:05
I think I misunderstand the question. Do you mean the question is to check if the whole string arr ...

对的,这样是对的。。当然用alien那题的思路check肯定没错,就是太复杂了。不知道层主还有什么好主意
回复

使用道具 举报

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

本版积分规则

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