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

🦴狗新鲜面经

🔗
yywwd 2020-2-16 05:33:01 | 只看该作者
全局:
queensberry 发表于 2020-2-15 03:16
第一题followup

[mw_shl_code=java,true]public String mnse(String s) {

能解释一下思路吗
回复

使用道具 举报

🔗
knight0clk 2020-2-16 08:27:41 | 只看该作者
全局:
edging1218 发表于 2020-2-15 01:55
第一题follow up greedy O(n)

请问greedy怎么做
回复

使用道具 举报

🔗
queensberry 2020-2-16 11:31:49 | 只看该作者
全局:
您好!
本帖隐藏的内容需要积分高于 100 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 100 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限 或 查看其他获取积分的方式
Unlock interview details and practice with AI
Curated Interview Questions from Top Companies

评分

参与人数 4大米 +5 收起 理由
Jess. + 1 给你点个赞!
Carofish + 1 给你点个赞!
miluChen + 1 赞一个
yywwd + 2 给你点个赞!

查看全部评分

回复

使用道具 举报

🔗
krystal1115 2020-2-16 12:44:24 | 只看该作者
全局:
queensberry 发表于 2020-2-16 11:31
first of all, what it means to be the shortest non subsequence of a string?
it means that if we  ...

那AABAA怎么办,最短是BB
回复

使用道具 举报

全局:
krystal1115 发表于 2020/02/16 12:44:24
那AABAA怎么办,最短是BB
根据我的算法跑下来是BB,因为碰到中间的B对应的是答案里第一个B,算法会检测到下一个字符是A从而append B到答案,你可以跑下代码
回复

使用道具 举报

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

使用道具 举报

🔗
duduhaha 2020-2-17 05:05:36 | 只看该作者
全局:
lyronly 发表于 2020-2-14 11:18
第四题建立 建立每个word 和其他所有word相同字符的maping 比如 相同字符6个的有3个word  相同字符5个的有2 ...

你这样做的理由是什么呢?为啥选最平均的?
回复

使用道具 举报

🔗
wantyoulee 2020-2-18 08:43:44 | 只看该作者
全局:
lyronly 发表于 2020-2-14 11:18
第四题建立 建立每个word 和其他所有word相同字符的maping 比如 相同字符6个的有3个word  相同字符5个的有2 ...

什么是最平均?为什么选最平均?
回复

使用道具 举报

🔗
leechuck 2020-2-18 09:00:18 | 只看该作者
全局:
第四题
  1. public void findSecretWord(String[] wordlist, Master master) {
  2.         List<String> words = Arrays.asList(wordlist);
  3.         while(true) {
  4.             String current = getMostOverlapWord(words);
  5.             int same_count = master.guess(current);
  6.             if (same_count == 6) break;
  7.             words = get_match_list(words, current, same_count);
  8.         }
  9.     }
  10.    
  11.     public List<String> get_match_list(List<String> words, String current, int count) {
  12.         List<String> res = new ArrayList<String>();
  13.         for (String word : words) {
  14.             if (word.equals(current)) continue;
  15.             int same = 0;
  16.             for (int j = 0; j < 6; j++) {
  17.                 if (current.charAt(j) == word.charAt(j)) same += 1;
  18.             }   
  19.             if (same == count) res.add(word);
  20.         }
  21.         return res;
  22.     }
  23.    
  24.     private String getMostOverlapWord(List<String> wordlist) {
  25.         int[] count = new int[26];        
  26.         for (String w : wordlist) {
  27.             for (char ch : w.toCharArray()) count[ch - 'a']++;
  28.         }
  29.         int maxScore = 0;
  30.         String bestWord = "";
  31.         // 所有words 里面 寻找最多字母重合的 word
  32.         for (String w : wordlist) {
  33.             int score = 0;
  34.             for (int i = 0; i < w.length(); i++) {
  35.                 score += count[w.charAt(i) - 'a'];
  36.             }
  37.             if (score >= maxScore) {
  38.                 maxScore = score;
  39.                 bestWord = w;
  40.             }
  41.         }
  42.         return bestWord;
  43.     }
复制代码
回复

使用道具 举报

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

本版积分规则

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