📣 黑五价提前开抢|VIP一年通行证5折,蓝莓、Offer多多同步特惠
楼主: 菡萏之默
跳转到指定楼层
上一主题 下一主题
收起左侧

FaceBook Onsite

🔗
dtcxzch 2015-1-23 10:01:19 | 只看该作者
全局:
第一题print path要求用iterative吗?还是就最简单的recursive的就行了?有没要求什么优化
回复

使用道具 举报

全局:
您好!
本帖隐藏的内容需要积分高于 100 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 100 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限 或 查看其他获取积分的方式
Unlock interview details and practice with AI
Popular Interview Questions from Top Companies
回复

使用道具 举报

🔗
shadowhunter 2015-3-7 23:06:50 | 只看该作者
全局:
在希望的田野上 发表于 2015-2-8 07:48
在 abc, cba 的情况下,有重复是因为枚举一个 word 的回文划分时,从左到右和右到左都考虑 empty string  ...

同意 和我的想法一样
回复

使用道具 举报

🔗
siren01 2015-3-19 09:10:44 | 只看该作者
全局:
  1. public List<List<String>> getPairs(Set<String> dict){
  2.                 List<List<String>> result = new ArrayList<List<String>>();
  3.                 for(String s:dict){
  4.                         for(int i=0 ; i<s.length(); ++i){
  5.                                 String s1 = s.substring(0, i);
  6.                                 String s2 = s.substring(i, s.length());
  7.                                 if(isPal(s1)){
  8.                                         judge(result, s, s2, dict, false);
  9.                                 }
  10.                                 if(isPal(s2)){
  11.                                         judge(result, s, s1, dict, true);
  12.                                 }
  13.                         }
  14.                 }
  15.                 return result;
  16.         }
  17.         public void judge(List<List<String>> result, String s, String compare, Set<String> dict, boolean position){
  18.                         char[] array = compare.toCharArray();
  19.                         for(int j=0; j<compare.length()/2; ++j){
  20.                                 char c = array[j];
  21.                                 array[j] = array[compare.length()-j-1];
  22.                                 array[compare.length()-j-1] = c;
  23.                         }
  24.                         String reverse = new String(array);
  25.                         if(dict.contains(reverse) && !reverse.equals(s)){
  26.                                 List<String> list = new ArrayList<String>();
  27.                                 if(position){
  28.                                         list.add(s);
  29.                                         list.add(reverse);
  30.                                 }
  31.                                 else{
  32.                                         list.add(reverse);
  33.                                         list.add(s);
  34.                                 }
  35.                                 result.add(list);
  36.                         }
  37.         }
  38.         public boolean isPal(String s){
  39.                 if(s.length()<=1)
  40.                         return true;
  41.                 int left = 0;
  42.                 int right = s.length()-1;
  43.                 while(left<right){
  44.                         if(s.charAt(left)!=s.charAt(right))
  45.                                 return false;
  46.                         ++left;
  47.                         --right;
  48.                 }
  49.                 return true;
  50.         }
复制代码
回复

使用道具 举报

🔗
bobzhang2004 2015-10-15 04:32:53 | 只看该作者
全局:
请问Power set是个什么题?
回复

使用道具 举报

🔗
returning 2016-3-27 09:48:06 | 只看该作者
全局:
bobzhang2004 发表于 2015-10-15 04:32
请问Power set是个什么题?

hello
你搞清楚了这是什么题没有?谢谢了。
回复

使用道具 举报

🔗
bobzhang2004 2016-3-27 12:54:03 | 只看该作者
全局:
returning 发表于 2016-3-27 09:48
hello
你搞清楚了这是什么题没有?谢谢了。

没啊。。。。
回复

使用道具 举报

🔗
sealove999 2016-4-5 02:28:31 | 只看该作者
全局:

这个帖子好老了,过了时效了咩
回复

使用道具 举报

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

本版积分规则

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