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

Coinbase OA

🔗
匿名用户-LKKQZ  昨天 09:04 |倒序浏览

2026(7-9月) 码农类General 硕士 全职@coinbase - 网上海投 - 在线笔试  | 😐 Neutral 😣 Hard | WaitList | 在职跳槽

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

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

x
Cloud Compute Credits System

Implement a simplified cloud compute credits system.

All operations have a timestamp parameter representing a timestamp in milliseconds.

All timestamps are unique.
1 <= timestamp <= 10^9
Operations are given in strictly increasing timestamp order.
Level 1 — Workspace Management and Credit Transfers

Initially, the system contains no workspaces.

The system should support creating workspaces, adding credits to workspaces, and transferring credits between workspaces.

boolean createWorkspace(int timestamp, String workspaceId)

Creates a new workspace with the given identifier.

Requirements:

The newly created workspace has an initial credit balance of 0.
Return true if the workspace is successfully created.
Return false if a workspace with the same workspaceId already exists.
Optional<Integer> topUp(int timestamp, String workspaceId, int amount)

Adds amount credits to the specified workspace.

Requirements:

If workspaceId does not exist, return Optional.empty().
Otherwise, add amount to the workspace's balance.
Return the workspace's balance after the top-up.
Optional<Integer> transferCredits(int timestamp, String sourceWorkspaceId, String targetWorkspaceId, int amount)

Transfers amount credits from the source workspace to the target workspace.

Return Optional.empty() if:

sourceWorkspaceId does not exist.
targetWorkspaceId does not exist.
sourceWorkspaceId and targetWorkspaceId are the same.
The source workspace has insufficient credits.

Otherwise:

Deduct amount from the source workspace.
Add amount to the target workspace.
Return the source workspace's remaining balance.
Level 2 — Rank Workspaces by Outgoing Credits

The platform wants to identify workspaces that drain their credits quickly.

The system should support ranking workspaces according to their total outgoing credit transactions.

List
您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限查看其他获取积分的方式
Unlock interview details and practice with AI
Curated Interview Questions from Top Companies
, 20) → 900

If no operation happened exactly at timeAt, return the balance resulting from the most recent operation before timeAt.

Workspace existence at timeAt

If the specified workspace did not exist at timeAt, return:

Optional.empty()

This applies in two situations.

If queried before creation:

t=10 create workspaceA


getCredits(..., "workspaceA", 5)
→ Optional.empty()

If queried after that workspace was merged away:

t=10 create workspaceB
t=30 merge B into A


getCredits(..., "workspaceB", 20)
→ B's balance at t=20


getCredits(..., "workspaceB", 30)
→ Optional.empty()


getCredits(..., "workspaceB", 40)
→ Optional.empty()

So even though workspaceB is no longer active, its pre-merge historical balance must remain queryable.

Merge and balance history

A merge affects the surviving workspace starting at the merge timestamp, not retroactively.

For example:

t=10:
A = 1700
B = 600


t=20:
merge B into A

Then:

getCredits(..., "A", 15)
→ 1700


getCredits(..., "B", 15)
→ 600


getCredits(..., "A", 20)
→ 2300


getCredits(..., "B", 20)
→ Optional.empty()

This distinction is especially important: B's old balance must not be added retroactively to A's pre-merge history.

评分

参与人数 1大米 +5 收起 理由
匿名用户-O64VL + 5 感谢分享!

查看全部评分


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

本版积分规则

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