回复: 7
跳转到指定楼层
上一主题 下一主题
收起左侧

2024年OA总结和题解

全局:

2024(10-12月) 码农类General 硕士 全职@Google - 内推 - 在线笔试  | 😃 Positive 😐 Average | Other | 在职跳槽

注册一亩三分地论坛,查看更多干货!

您需要 登录 才可以下载或查看附件。没有帐号?注册账号

x

因为分数的原因,有些部分没有看到。后面看到了,再补充。
You are given an array A of N integers. You can split the array into two not-empty parts, left and right, sort the elements in each parts, left and right, sort the elements in each part independently and join them back together. 
For example, given array A =[1, 3, 2, 4], you can split it in the following three ways: 
left=[1], right = [3, 2, 4]. Sorting the elements and joining the parts back together results in the array:[1, 2, 3, 4]
left=[1, 3], right =[2, 3], Resulting sorted and rejoined array: [1, 3, 2, 4]
left=[1, 3, 2], right = [4]. Resulting sorted and rejoined array: [1, 2, 3, 4]
Your task is to find the number of ways of splitting the array into two parts such that, after sorting the two parts and rejoining them into a single array, the resulting array will be sorted in non-decreasing order. For the array shown above, the answer is 2: the first and the third splits result in a sorted array. Write a function. 


3, Given A = [5, 5, 5] the function should return 2. The splits that result in a sorted array are:
left=[5], right=[5, 5]
left=[5, 5], right=[5]


4, Given A=[3, 1 ,2], the function should return 0. There are no splits that would result in a sorted array.


这道题的为了找,左分组的最大值小于等于右分组的最小值的个数。Max(Left[0:i])<=Min(Ri
您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限 或 查看其他获取积分的方式
Unlock interview details and practice with AI
Popular Interview Questions from Top Companies
#160;   for (int i = n - 2; i >= 0; --i) {
        rightMin[i] = min(rightMin[i + 1], A[i]);
    }
    // Step 2: Count valid splits
    int validSplits = 0;
    for (int i = 0; i < n - 1; ++i) {
        if (leftMax[i] <= rightMin[i + 1]) {
            validSplits++;
        }
    }
    return validSplits;
}
int main() {
    // Test cases
    cout << countValidSplits({1, 3, 2, 4}) << endl; // Output: 2
    cout << countValidSplits({5, 5, 5}) << endl;    // Output: 2
    cout << countValidSplits({3, 1, 2}) << endl;    // Output: 0
    return 0;
}
Java版我自己写,其他用的ChatGPT,略有不同,不清楚的可以问。

评分

参与人数 2大米 +11 收起 理由
小葱头丫 + 1 很有用的信息!
匿名用户-FUKQJ + 10 欢迎分享你知道的情况,会给更多大米奖励!

查看全部评分


上一篇:买它 NG VO,求linkedin meta比较
下一篇:Databricks 全程面经
🔗
 楼主| yangzhit 2024-11-9 19:14:18 | 只看该作者
全局:
您好!
本帖隐藏的内容需要积分高于 100 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 100 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限 或 查看其他获取积分的方式
Unlock interview details and practice with AI
Popular Interview Questions from Top Companies
回复

使用道具 举报

地里匿名用户
🔗
匿名用户-QC79A  2024-11-9 23:12:22
感谢分享! 请问面的什么level? google所有岗位都有oa吗?
回复

使用道具 举报

🔗
 楼主| yangzhit 2024-11-10 04:53:32 | 只看该作者
全局:
匿名用户 发表于 2024-11-9 07:12
感谢分享! 请问面的什么level? google所有岗位都有oa吗?

我面的是Principal/Senior的职位,内推申请了3个职位,已经拒了一个。30分钟那种,估计是Behavior,不是上面的Coding。第一次OA,以前面不需要。
回复

使用道具 举报

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

使用道具 举报

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

使用道具 举报

🔗
xx是星星 2024-12-14 00:53:15 | 只看该作者
全局:
同收到30min的bq问题,想问问楼主有follow up了吗?
回复

使用道具 举报

🔗
 楼主| yangzhit 2024-12-14 08:18:36 | 只看该作者
全局:
xx是星星 发表于 2024-12-13 08:53
同收到30min的bq问题,想问问楼主有follow up了吗?

热带雨林面挂了, https://www.1point3acres.com/bbs/thread-1102454-1-1.html, 在准备灭他。
之前总结的设计可以看这里。
2024年灭他设计和题解 https://www.1point3acres.com/bbs/thread-1099798-1-1.html
2024年亚麻设计和题解 https://www.1point3acres.com/bbs/thread-1099160-1-1.html
2024年Google 设计和题解 https://www.1point3acres.com/bbs/thread-1097035-1-1.html
回复

使用道具 举报

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

本版积分规则

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