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

Upstart CodePad OA 原题

🔗
匿名用户-SNRGX  3 天前 |倒序浏览

2026(7-9月) 码农类General 硕士 全职@upstart - 网上海投 - 在线笔试  | 😃 Positive 😐 Average | Other | 在职跳槽

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

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

x
1. adjust_quantities
You have the ingredient list of a one-person recipe. You want to cook it for many persons (defined by
  1. nb_persons
复制代码
). So, you must multiply all the quantities.
The ingredient list consists of strings, each defining a specific product. They all have the following format:
  • An integer (written with digits), defining the quantity.
  • A space character.
  • Some words, defining the product.
Modify the string by multiplying the initial integer by
  1. nb_persons
复制代码
.
You do not have to take care of the singular/plural of the words defining the product. These words may contain some numbers, you must not modify them.
The order of the lines must be preserved.
Example
You want to cook a cake for 3 persons. Here is the initial ingredient list for one person:
2 eggs
200 grams of flour
150 grams of sugar
1 liter(s) of milk
You must output this list:
6 eggs
600 grams of flour
450 grams of sugar
3 liter(s) of milk
Implementation
Implement the function
  1. adjust_quantities
复制代码
.
Parameters
    1. nb_persons
    复制代码
    (int): Number of persons for which to prepare the recipe. Strictly positive integer.
    1. ingredients
    复制代码
    (List[str]): List of ingredients. All of them start with an integer, strictly positive.
Return value
  1. output
复制代码
(List[str]): List of ingredients, with quantities multiplied by the number of persons.
Constraints
  • Available RAM: 512MB
  • Timeout: 6 seconds
2. filter_duplicates
Implement the function[        DISCUZ_CODE_6
您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限查看其他获取积分的方式
Unlock interview details and practice with AI
Curated Interview Questions from Top Companies
t]): Sequence of arrivals and departures of guests.Return value
  1. output
复制代码
(int): The total gains of the day.
Constraints
  • 1 <= length(
    1. paying_guests
    复制代码
    ) <= 10
  • 2 <= length(
    1. guest_movements
    复制代码
    ) <= 26
  • Available RAM: 512MB
  • Timeout: 6 seconds
Example
Parameters (arrays are truncated in the screenshot):
100
(6) [45, 10, 25, 30, 15, …]
(8) [3, 3, 0, 4, 0, 2, 2, …]
Return value:
115
AI follow-up
In your loop, when a guest ID is found in
  1. waiting
复制代码
, you remove that guest from the queue rather than moving them into
  1. seated
复制代码
. What situation in the input does this branch represent, and how does your code distinguish it from a guest's departure after being seated?
This question was generated by AI. It may contain errors.

评分

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

查看全部评分


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

本版积分规则

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