楼主: 谁的时延
跳转到指定楼层
上一主题 下一主题
收起左侧

Google onsite 面经

🔗
bobzhang2004 2015-12-1 11:06:19 | 只看该作者
全局:
请问第一题两个array之间需要有间隔吗?比如“Hello WorldHell World"还是需要是 “Hello World Hello World"。还有一个word如果大于n怎么办?就得返回0?

补充内容 (2015-12-1 11:06):
两个string
回复

使用道具 举报

🔗
Alice0701 2016-3-14 05:03:57 | 只看该作者
全局:
谢谢LZ 我也要继续加油!!
回复

使用道具 举报

🔗
bobzhang2004 2016-4-1 09:09:36 | 只看该作者
全局:
snail_914 发表于 2015-11-26 05:50
不知道楼主现在有结果了吗 保佑
关于第四轮, 不明白为什么不直接用HashSet 加双指针, 一个fas ...

这个题应该所有easy题吧,难点在哪呢?
回复

使用道具 举报

🔗
bobzhang2004 2016-4-1 09:30:00 | 只看该作者
全局:
写了下第一题
  1. public class ScreenWords {

  2.         public static void main(String[] args) {
  3.                 String str = "Hello World";
  4.                 System.out.println(getNumberOfWordsCanPutInScreen(2, 17, str));
  5.                 str = "Hello Worlds";
  6. //                System.out.println(getNumberOfWordsCanPutInScreen(1, 11, str));
  7.         }
  8.        
  9.         public static int getNumberOfWordsCanPutInScreen(int m, int n, String str) {
  10.                 if (str.length() > n) {
  11.                         return 0;
  12.                 }
  13.                
  14.                 String[] words = str.split(" ");
  15.                 int i = 0;
  16.                 int j = 0;
  17.                 int count = 0;
  18.                 while (i < m) {
  19.                         int len = -1;
  20.                         while (len + words[j].length() + 1 <= n) {
  21.                                 len += words[j].length() + 1;
  22.                                 j++;
  23.                                 if (j == words.length) {
  24. //                                        System.out.println(count + " " + words.length + " " + j);
  25.                                         j = 0;
  26.                                         count++;
  27.                                 }
  28.                                
  29.                         }
  30.                        
  31.                         i++;
  32.                 }
  33.                
  34.                 return count;
  35.         }
  36. }
复制代码
回复

使用道具 举报

🔗
mdyuki1016 2016-4-1 09:37:56 | 只看该作者
本楼:
全局:
感谢楼主
回复

使用道具 举报

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

本版积分规则

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