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

亚麻 SDE2 OA

🔗
匿名用户-GOG3V  2025-1-31 06:38:38 |倒序浏览

2024(10-12月) 码农类General 硕士 全职@Amazon - 猎头 - 在线笔试  | 😐 Neutral 😐 Average | Fail | 在职跳槽

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

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

x


Code Question 1

At Amazon, a user owns a unique tool called the "Parentheses Perfection Kit." This kit contains different types of parentheses, each with a specific efficiency rating. The goal is to create a balanced sequence of parentheses by adding zero or more parentheses from the kit to maximize the sequence's total EfficiencyScore. The EfficiencyScore of a sequence is the sum of the efficiency ratings of the parentheses used from the kit.
A sequence is considered balanced if it has an equal number of opening '(' and closing ')' parentheses, with each opening parentheses properly matched with a closing one in the correct order (i.e., circular balance). For instance, sequences like ((),(), and (((())) are balanced, while sequences like ), ((), and (())( are not.
You are given an initial parentheses sequence represented by the string ss, along with a Parentheses Perfection Kit containing different types of parentheses in the form of the string kitParentheses and their respective efficiency ratings in the efficiencyRatings array (both of size m). The EfficiencyScore of the original string ss is initially 0. You can use any number of unused parentheses from the kit to create the final sequence, as long as the final sequence remains balanced.
The task is to determine the maximum possible EfficiencyScore that can be achieved for the resulting balanced sequence.
Note: It is guaranteed that the sequence can be made balanced by adding zero or more parentheses from the kit.Example

s="(("s=&quo
您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限查看其他获取积分的方式
Unlock interview details and practice with AI
Curated Interview Questions from Top Companies
changing their order.
Language Java 8
& Autocomplete Ready

  • import java. 10.*:
    14
    15
    16
    class Result (
    17
    18



Hint: It can be proved that (a + b) % c = ((a % c) + (b % c)) % c where a, b,
and c are integers and % represents the modulo operation.
Function Description
Complete the function getMinErrors in the editor below.
19
20

  • Complete the 'getMinErrors' function below.
  • The function is expected to return an
    21
    getMinErrors has the following parameter(s):
    string errorString: a string of characters 'O', '1', and 'T' int x: the number of errors generated for every occurrence of
    subsequence 01
    int y: Ithe number of errors generated for every occurrence of
    subsequence 10
    INTEGER.
  • The function accepts Following parameters:
  • 1, STRING errorString
  • INTEGER *
  • INTEGER Y



Returns
int: the minimum number of errors possible, modulo 10^9+7


Constraints
• 1 ≤ len(errorString) ≤ 10^5
• 0 ≤ x, y ≤ 10^5
• s consists only of characters 'O', 'T, and '!'

评分

参与人数 2大米 +12 收起 理由
影子冷峰 + 2 很有用的信息!
匿名用户-6KYTY + 10 欢迎分享你知道的情况,会给更多大米奖励!

查看全部评分


上一篇:亚马intern VO
下一篇:Confluent电面
推荐
serein 2025-2-11 11:44:56 | 只看该作者
全局:
回复

使用道具 举报

地里匿名用户
推荐
匿名用户-SGDDX  2025-2-4 01:22:36
回复

使用道具 举报

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

本版积分规则

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