📣 黑五网一特惠|VIP一年通行证5折,蓝莓、Offer多多同步特惠
回复: 9
跳转到指定楼层
上一主题 下一主题
收起左侧

TT 3.8-3.12 oa coding

全局:

2025(1-3月) 码农类General 硕士 全职@bytedance - 网上海投 - 在线笔试  | 😐 Neutral 😣 Hard | Other | 应届毕业生

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

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

x

第六题
TikTok Viral Campaign
TikTok is a widely - used social media platform where users follow influencers who shape their content preferences. Formally, if user A follows user B, then user A is said to be influenced by user B. Once a user is influenced by a trend, they immediately propagate this information to all users who follow them.
As a brand manager tasked with designing a viral campaign, your objective is to determine the minimum number of users who need to be initially targeted with the trend, such that the information eventually reaches every user on the platform. If a user is neither an influencer nor a follower, they are still a TikTok user and must be directly introduced to the viral campaign independently.
You are given an integer n, representing the total number of TikTok users, along with two lists - influencers and followers - each of size n. For each index i, influencers[i] represents an influencer and followers[i] represents the user who follows that influencer. (If followers[i] is - 1, it indicates that the corresponding influencer has no followers.)
It is important to note the following:
Some users may not have any followers. In such cases, followers[i] will be set to - 1, indicating that the corresponding influencer is not followed by anyone.
There may be mutual follow relationships, i.e., user a may follow user b, and user b may follow user a.
Some users might appear in the influ
您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限 或 查看其他获取积分的方式
Unlock interview details and practice with AI
Popular Interview Questions from Top Companies
o non - empty groups
Constraints
1 ≤ n ≤ 10^5
1 ≤ videoChunks[i] ≤ 10^9
1 ≤ k ≤ n
Input Format For Custom Testing
Sample Case 0
Sample Input For Custom Testing |STDIN|FUNCTION| |----|----| |7|videoChunks[] size n = 7| |8|videoChunks = [8, 9, 8, 2, 9, 9, 2]| |9| |8| |2| |9| |9| |2| |3|k = 3|
Sample Output 31
Explanation Given n = 7, videoChunks = [8, 9, 8, 2, 9, 9, 2], and k = 3. One of the optimal way is to partition the array into these three subarrays: [[8, 9, 8], [2, 9, 9], [2]].
Cost of first subarray = 8 + 8 = 16
Cost of second subarray = 2 + 9 = 11
Cost of third subarray = 2 + 2 = 4
Total cost = 16 + 11 + 4 = 31 It can be shown that the sum of the costs cannot be less than 31. Hence, the minimum total cost is 31.
只做出来第七题,第六题太难了,不会做,求大米看看其他面经

评分

参与人数 5大米 +19 收起 理由
yufeibai + 1 给你点个赞!
carrotjuice + 1 很有用的信息!
于倩 + 1 谢谢分享!
匿名用户-MTHK7 + 15 欢迎分享你知道的情况,会给更多大米奖励!
1亩6分地_ + 1 赞一个

查看全部评分


上一篇:现在面试都有shadow了吗?最近碰到的几个全部都是有shadow
下一篇:Nextdoor rescinded Offer & Hiring Freeze 请避雷!
推荐
 楼主| Easonnn 2025-3-12 02:15:08 | 只看该作者
全局:
biology000 发表于 2025-3-10 23:20
大佬有第三题 第四 第五题吗

编程题只有两题,其余选择题用gpt做
回复

使用道具 举报

推荐
biology000 2025-3-11 14:20:56 | 只看该作者
全局:
大佬有第三题 第四 第五题吗
回复

使用道具 举报

🔗
zhangyuwinnie 2025-3-11 14:04:59 | 只看该作者
全局:
也许是不是可以用BFS处理,找出ingres 为0的users作为head (这里有点不确定,可能需要扣除互相follow的ingres), 然后尽量 traverse, 最后结果大概是几个head+离散的没有被traverse 到的user
回复

使用道具 举报

🔗
carrotjuice 2025-3-13 09:35:35 | 只看该作者
全局:
谢谢lz 完全一样
第六题tarjan算scc
第七题ez
回复

使用道具 举报

地里匿名用户
🔗
匿名用户-JFKHQ  2025-3-13 11:14:24
Easonnn 发表于 2025-3-11 14:15
编程题只有两题,其余选择题用gpt做

不是要开摄像头吗, 怎么GPT 操作
回复

使用道具 举报

地里匿名用户
🔗
匿名用户-JFKHQ  2025-3-13 11:15:40
carrotjuice 发表于 2025-3-12 21:35
谢谢lz 完全一样
第六题tarjan算scc
第七题ez

什么是ez啊
回复

使用道具 举报

地里匿名用户
🔗
匿名用户-JFKHQ  2025-3-13 11:17:05
感谢楼主 祝好运
回复

使用道具 举报

🔗
carrotjuice 2025-3-18 07:12:11 | 只看该作者
全局:

就很简单啊 想像如果只先加收尾是多少 分的块其实也就比这个数多一个第n和第n+1个的和 for loop只跑一遍就行
回复

使用道具 举报

地里匿名用户
🔗
匿名用户-SPLND  2025-8-9 22:47:41 来自APP
想问一下OA有时间限制吗?谢谢楼主!
回复

使用道具 举报

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

本版积分规则

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