📣 黑五价提前开抢|VIP一年通行证5折,蓝莓、Offer多多同步特惠
12
返回列表 发新帖
楼主: luisyan711
跳转到指定楼层
上一主题 下一主题
收起左侧

买他电面

🔗
 楼主| luisyan711 2023-9-7 21:23:35 来自APP | 只看该作者
全局:
匿名用户 发表于 2023-09-07 00:51:20
请教是需要把代码跑起来 还是只是写完就可以了?
不编译 相当于白板写code 需要嘴上跑test case

评分

参与人数 1大米 +1 收起 理由
jajaas + 1 赞一个

查看全部评分

回复

使用道具 举报

🔗
Jonson 2023-9-8 06:24:57 | 只看该作者
全局:
找到类似的第一题
  1. Given a non-empty array nums contains positive integers and a positive integer target.
  2. Find the first subarray in nums that sums up to target and return the begin and end index of this subarray. If there is no such subarray, return [-1, -1].

  3. Example 1:

  4. Input: nums = [4, 3, 5, 7, 8], target = 12
  5. Output: [0, 2]
  6. Explanation: 4 + 3 + 5 = 12. Although 5 + 7 = 12, [4, 3, 5] is the first subarray that sums up to 12.
  7. Example 2:

  8. Input: nums = [1, 2, 3, 4], target = 15
  9. Output: [-1, -1]
  10. Explanation: Thers is no such subarray that sums up to 15.
复制代码
Solution:
  1.   private static int[] solution(final int[] array, final int target) {
  2.       int start = 0;
  3.       int end = 0;
  4.       int sum = 0;
  5.       int[] result = new int[2];

  6.       while (end != array.length) {
  7.         sum = sum + array[end];

  8.         if (sum == target) {
  9.           result[0] = start;
  10.           result[1] = end;
  11.           break;
  12.         }

  13.         if (sum > target) {
  14.           sum = sum - array[start];
  15.           start++;
  16.         }

  17.         if (sum < target) {
  18.           end++;
  19.         }
  20.       }

  21.       return result;
  22.     }
复制代码

评分

参与人数 1大米 +1 收起 理由
LXU + 1 赞一个

查看全部评分

回复

使用道具 举报

🔗
Anthony-Time 2023-9-17 03:18:37 | 只看该作者
全局:
楼主多久出结果呢
回复

使用道具 举报

🔗
 楼主| luisyan711 2023-9-17 04:10:18 | 只看该作者
全局:

面完隔了一天recruiter email说过了
回复

使用道具 举报

地里匿名用户
🔗
匿名用户-J440D  2023-9-17 05:08:04 来自APP
楼主太幸运了,国人面试官出的这两题异常简单
回复

使用道具 举报

🔗
 楼主| luisyan711 2023-9-17 05:16:48 | 只看该作者
全局:
匿名用户 发表于 2023-9-16 16:08
楼主太幸运了,国人面试官出的这两题异常简单

是啊 十分感谢这位国人大哥
回复

使用道具 举报

🔗
TimTime2019 2023-9-19 10:44:53 | 只看该作者
全局:

奇拉比 也是zszs
回复

使用道具 举报

🔗
123zzz321 2023-9-23 15:52:53 | 只看该作者
全局:
第一题舞耳散?
回复

使用道具 举报

地里匿名用户
🔗
匿名用户-ND4JH  2023-11-2 17:07:53
是面加拿大E4吗?LZ最后拿到offer了吗
回复

使用道具 举报

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

本版积分规则

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