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

丢盒子 | Dropbox Internship OA

全局:

2022(1-3月) 工程类 本科 实习@dropbox - 校园招聘会 - 在线笔试  | 🙁 Negative 😫 Hardest | Other | 应届毕业生

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

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

x
Your task is to implement a simplified version of text editor.

All operations that should be supported are listed below. Partial credit will be given for each implemented operation. Please submit often to ensure partial credits are captured.

Implementation tips

Implement operations and provided steps one by one, and not all together, keeping in mind that you will need to make refactors to support each additional step. In the first three levels you can assume that only one text document is modified.

Note

After every operation, add the current state of the text to the resulting array. The returning array should consist of all the states after each operation is applied and have the same length as the # of input queries.
Level 1

The editor starts with a blank text document, with the cursor at initial position 0.

1. APPEND <text> should append the inputted string text to the document starting from the current position of the cursor. After the operation, the cursor should be at the end of the added string.

queries = [
    ["APPEND", "Hey"],                | "" -> "Hey"
    ["APPEND", " there"],             | "Hey" -> "Hey there"
    ["APPEND", "!"]                   | "Hey there" -> "Hey there!"
]

// returns: [ "Hey",
//            "Hey there",
//            "Hey there!" ]

2. MOVE <position> should move the cursor to the specified position. The cursor should be positioned between document characters, and are enumerated sequentially starting from 0. If the specified position is out of bounds, then move the cursor to the nearest available position.

queries = [
    ["APPEND", "Hey you"],            | "" -> "Hey you"
    ["MOVE", "3"],                    | moves the cursor after the first "y"
    ["APPEND", ","]                   | "Hey you" -> "Hey, you"
]

// returns: [ "Hey you",
//            "Hey you",
//            "Hey, you" ]

3. FORWARD_DELETE should remove the character right after the cursor, if any.

queries = [
    ["APPEND", "Hello! world!"],      | "" -> "Hello! world!"
    ["MOVE", "5"],                    | moves the cursor before the first "!"
    ["FORWARD_DELETE"],               | "Hello! world!" -> "Hello world!"
    ["APPEND", ","]                   | "Hello world!" -> "Hello, world!"
]

// returns: [ "Hello! world!",
//            "Hello! world!",
//            "Hello world!",
//            "Hello, world!" ]

and

queries = [
    ["APPEND", "!"],                  | "" -> "!"
    ["FORWARD_DELETE"],               | "!" -> "!"
    ["MOVE", "0"],                    | moves the cursor before the first symbol
    ["FORWARD_DELETE"],               | "!
您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限 或 查看其他获取积分的方式
Unlock interview details and practice with AI
Popular Interview Questions from Top Companies
         | switches to document2
    ["PASTE"],                        | document2: "" -> "world"
    ["SWITCH", "document1"],          | switches to document1
    ["FORWARD_DELETE"]                | document1: "Hello, !" -> "Hello,!"
]

// returns: [ "",
              "",
              "",
              "",
              "Hello, world!",
              "Hello, world!",
              "Hello, !",
              "",
              "world",
              "Hello, !",
              "Hello,!" ]

Example

For

queries = [
    ["APPEND", "Hey"],
    ["APPEND", " you"],
    ["APPEND", ", don't"],
    ["APPEND", " "],
    ["APPEND", "let me down"]
]

the output should be

solution(queries) = [
    "Hey",
    "Hey you",
    "Hey you, don't",
    "Hey you, don't ",
    "Hey you, don't let me down"
]

Input/Output

    [execution time limit] 4 seconds (py3)

    [input] array.array.string queries

    An array of operations need to be applied to the text editor. It is guaranteed that each operation is one of the operations described in the description, all operation parameters are given in correct format, and the text editor will never be in an incorrect state that is not described in the description.

    Guaranteed constraints:
    1 ≤ queries.length ≤ 250.

    [output] array.string

    After every operation, add the current state of the text to the resulting array. The returning array should consist of all the states after each operation is applied and have the same length as the # of input queries.

[Python 3] Syntax Tips

# Prints help message to the console
# Returns a string
def helloWorld(name):
    print("This prints to the console when you Run Tests")
    return "Hello, " + name



评分

参与人数 3大米 +27 收起 理由
leetcodeisgood + 1 很有用的信息!
chosenischosen + 1 谢谢分享!
匿名用户-T3UDT + 25

查看全部评分


上一篇:Tesla糟糕至极的面试体验
下一篇:热带雨林 SDE I 现场表演挂经
🔗
 楼主| xgcjosh 2022-3-14 11:52:35 | 只看该作者
全局:
走过路过求大米!! 谢谢你
回复

使用道具 举报

🔗
 楼主| xgcjosh 2022-3-14 11:52:45 | 只看该作者
全局:
本帖最后由 xgcjosh 于 2022-3-13 20:54 编辑

祝大家好运   
回复

使用道具 举报

🔗
cutehuazai 2022-3-14 14:28:20 | 只看该作者
全局:
楼主是啥时候投的然后多久收到的OA
回复

使用道具 举报

地里匿名用户
🔗
匿名用户-B98EN  2022-3-15 00:11:40
请问楼主timeline   zszszs
回复

使用道具 举报

🔗
 楼主| xgcjosh 2022-3-16 08:55:21 | 只看该作者
全局:
cutehuazai 发表于 2022-3-13 23:28
楼主是啥时候投的然后多久收到的OA

03/03 申请

03/11 OA
回复

使用道具 举报

🔗
 楼主| xgcjosh 2022-3-16 08:55:27 | 只看该作者
全局:
cutehuazai 发表于 2022-3-13 23:28
楼主是啥时候投的然后多久收到的OA

03/03 申请

03/11 OA
回复

使用道具 举报

地里匿名用户
🔗
匿名用户-PQHT3  2022-3-17 00:48:27
做完之后有下一步联系楼主吗,谢谢
回复

使用道具 举报

🔗
oonlyxx713 2022-3-19 10:53:32 | 只看该作者
全局:
lz 内推还是海投呢 为啥我收不到oa呀
回复

使用道具 举报

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

本版积分规则

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