R公司面经

版主: bestsuisiG342886bestsuisiG342886

回复
tina
帖子: 5
注册时间: 周二 3月 07, 2023 7:51 am

R公司面经

帖子 tina »

/*
As you are reading the book multiple times, you notice that you often get bad endings. You start to suspect there is no way to get to the good endings, so you decide to find out.

Good and bad endings will be separate lists of page numbers, like this:

good_endings = [10, 15, 25, 34]
bad_endings = [21, 30, 40]

Given lists of good endings, bad endings, and a list of the choices along with their options, return a collection of all the reachable good endings, if any.

Examples:

choices1 = [[3, 16, 24]]
find_good_endings(good_endings, bad_endings, choices1)
Start: 1 -> 2 -> 3(choice) -> 16 -> 17... -> 21(bad ending)
|
-> 24 -> 25(good ending)
Thus it is possible to reach the good ending at 25 but no others, so we return [25].

choices2 = [[3, 16, 20]]
find_good_endings(good_endings, bad_endings, choices2)
Start: 1 -> 2 -> 3(choice) -> 16 -> 17... -> 21(bad ending)
|
> 20 -> 21(bad ending)
No good ending is reachable, so return [].

choices3 = [[3, 16, 19], [20, 2, 17]]
find_good_endings(good_endings, bad_endings, choices3)
+------<-------<----+
v |
Start: 1 -> 2 -> 3(choice) -> 16 -> 17 -> 18 -> 19 -> 20(choice)
^ | ^ |
| +----->------->------>------+ v
+-------<--------<-------<-------<----------+

No good ending is reachable, so return [].

Additional Inputs:
choices4 = [[3, 2, 19], [20, 21, 34]]
choices5 = []
choices6 = [[9, 16, 26], [14, 16, 13], [27, 29, 28], [28, 15, 34], [29, 30, 38]]
choices7 = [[9, 16, 26], [13, 31, 14], [14, 16, 13], [27, 12, 24], [32, 34, 15]]
choices8 = [[3, 9, 10]]
choices9 = [[3, 9, 10], [12, 13, 14]]

Complexity Variable:
n = number of pages
(endings and choices are bound by the number of pages)

All Test Cases - snake_case:
find_good_endings(good_endings, bad_endings, choices1) => [25]
find_good_endings(good_endings, bad_endings, choices2) => []
find_good_endings(good_endings, bad_endings, choices3) => []
find_good_endings(good_endings, bad_endings, choices4) => [34]
find_good_endings(good_endings, bad_endings, choices5) => [10]
find_good_endings(good_endings, bad_endings, choices6) => [15, 34]
find_good_endings(good_endings, bad_endings, choices7) => [15, 25, 34]
find_good_endings(good_endings, bad_endings, choices8) => [10]
find_good_endings(good_endings, bad_endings, choices9) => [10]
*/
tina
帖子: 5
注册时间: 周二 3月 07, 2023 7:51 am

Re: R公司面经

帖子 tina »

roblox 分享一下面经
1. coding:输入是一个字符串数组,如果数组中的元素是其它元素的prefix,将它从数组中去掉,并且保持元素间的顺序不变。比如输入 a = ['a', 'b', 'ab', 'abc'], 输出 ['b', 'abc'] ,去掉‘a'和'ab'因为'a'是'ab'和'abc'的prefix,'ab'是'abc'的prefix。
2. creative problem solving:如果你可以调动公司的任何资源,如果吸引更多的用户
3. system design:设计一个todo list service,可以将list分享给其他人,被分享的人也可以修改list的内容
4. system design 2: 讲一个过去的project,对方提问。
5 bq
回复