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

roblox面经汇总

   
🔗
匿名用户-5874P  2023-11-11 16:36:13 |倒序浏览

2023(7-9月) 码农类General 硕士 全职@roblox - 网上海投 - 技术电面 Onsite 视频面试  | 😃 Positive 😣 Hard | Pass | 在职跳槽
之前准备roblox的面试,把能搜到的面经都过了一遍,coding都写了出来
附件一个是所有coding,一个是system design和behavior的大杂烩

电面和onsite面到的题都在我自己总结的面经里了,也拿到了offer,可惜最后没有去

希望对之后准备他家的朋友们有用,顺便求点大米,最近又有面试要准备,十分感谢!


update:
复制粘贴,以下!
  1. ##################################################################
  2. ### 528. Random Pick with Weight
  3. ##################################################################
  4. import random

  5. class Solution(object):

  6.     def __init__(self, w):
  7.         self.cumm_w = [w[0] for _ in range(len(w))]
  8.         self.total_w = sum(w)
  9.         
  10.         for i in range(1, len(w)):
  11.             self.cumm_w[i] = self.cumm_w[i - 1] + w[i]
  12.         
  13.     # linear search
  14.     def pickIndex(self):
  15.         num = random.random() * self.total_w
  16.         for i, weight in enumerate(self.cumm_w):
  17.             if num < weight:
  18.                 return i
  19.    
  20.     # binary search
  21.     def pickIndex(self):
  22.         num = random.random() * self.total_w
  23.         l, r = 0, len(self.cumm_w) - 1
  24.         while l < r:
  25.             mid = (l + r) // 2
  26.             if num > self.cumm_w[mid]:
  27.                 l = mid + 1
  28.             else:
  29.                 r = mid
  30.         return l

  31. # Your Solution object will be instantiated and called as such:
  32. # obj = Solution(w)
  33. # param_1 = obj.pickIndex()
  34. ##################################################################
  35. ### 1197. Minimum Knight Moves
  36. ##################################################################
  37. from collections import deque

  38. class Solution(object):
  39.     # Bidirectional BFS: (max(∣x∣,∣y∣)) ** 2
  40.     def minKnightMoves(self, x, y):
  41.         offsets = [(1, 2), (2, 1), (-1, 2), (-2, 1),
  42.                    (1, -2), (2, -1), (-1, -2), (-2, -1)]
  43.         origin_queue = deque([(0, 0, 0)])
  44.         origin_dis = {(0, 0): 0}
  45.         
  46.         target_queue = deque([(x, y, 0)])
  47.         target_dis = {(x, y): 0}
  48.         
  49.         while origin_queue or target_queue:
  50.             
  51.             origin_x, origin_y, origin_step = origin_queue.popleft()
  52.             if (origin_x, origin_y) in target_dis:
  53.                 return origin_step + target_dis[(origin_x, origin_y)]
  54.             
  55.             target_x, target_y, target_step = target_queue.popleft()
  56.             if (target_x, target_y) in origin_dis:
  57.                 return target_step + origin_dis[(target_x, target_y)]
  58.             
  59.             for offset_x, offset_y in offsets:
  60.                 next_origin_x, next_origin_y = origin_x + offset_x, origin_y + offset_y
  61.                 next_target_x, next_target_y = target_x + offset_x, target_y + offset_y
  62.                
  63.                 if (next_origin_x, next_origin_y) not in origin_dis:
  64.                     origin_queue.append((next_origin_x, next_origin_y, origin_step + 1))
  65.                     origin_dis[(next_origin_x, next_origin_y)] = origin_step + 1
  66.                     
  67.                 if (next_target_x, next_target_y) not in target_dis:
  68.                     target_queue.append((next_target_x, next_target_y, target_step + 1))
  69.                     target_dis[(next_target_x, next_target_y)] = target_step + 1
  70.             
  71.         return -1
  72.                
  73.     # BFS
  74.     def minKnightMoves(self, x, y):
  75.         offsets = [(1, 2), (2, 1), (-1, 2), (-2, 1),
  76.                   (1, -2), (2, -1), (-1, -2), (-2, -1)]
  77.         queue = deque([(0, 0, 0)])
  78.         visited = set()
  79.         while queue:
  80.             pos_x, pos_y, step = queue.popleft()
  81.             if pos_x == x and pos_y == y:
  82.                 return step
  83.             
  84.             visited.add((pos_x, pos_y))
  85.             for i, j in offsets:
  86.                 if (pos_x + i, pos_y + j) in visited:
  87.                     continue
  88.                 queue.append((pos_x + i, pos_y + j, step + 1))
  89.             
  90.         return -1

  91. ##################################################################
  92. ### 207. Course Schedule
  93. ##################################################################
  94. from collections import deque
  95. from collections import defaultdict

  96. class Solution(object):
  97.     def canFinish(self, numCourses, prerequisites):
  98.         """
  99.         :type numCourses: int
  100.         :type prerequisites: List[List[int]]
  101.         :rtype: bool
  102.         """
  103.         inDegree = defaultdict(int)
  104.         dependencyMap = defaultdict(list)
  105.         for x, y in prerequisites:
  106.             inDegree[y] += 1
  107.             dependencyMap[x].append(y)
  108.         
  109.         queue = deque()
  110.         for i in range(numCourses):
  111.             if i not in inDegree:
  112.                 queue.append(i)
  113.         
  114.         result = 0
  115.         while queue:
  116.             curr_course = queue.popleft()
  117.             result += 1
  118.             for neighbor in dependencyMap[curr_course]:
  119.                 inDegree[neighbor] -= 1
  120.                 if inDegree[neighbor] == 0:
  121.                     queue.append(neighbor)
  122.         
  123.         return True if result == numCourses else False
  124. ##################################################################
  125. ### 210. Course Schedule II
  126. ##################################################################
  127. from collections import deque
  128. from collections import defaultdict

  129. class Solution(object):
  130.     def findOrder(self, numCourses, prerequisites):
  131.         """
  132.         :type numCourses: int
  133.         :type prerequisites: List[List[int]]
  134.         :rtype: List[int]
  135.         """
  136.         in_degree_count = defaultdict(int)
  137.         dependency_graph = defaultdict(set)
  138.         for prereq in prerequisites:
  139.             a, b = prereq[0], prereq[1]
  140.             in_degree_count[a] += 1
  141.             dependency_graph[b].add(a)
  142.         
  143.         queue = deque()
  144.         for i in range(numCourses):
  145.             if in_degree_count[i] == 0:
  146.                 queue.append(i)
  147.         
  148.         order = []
  149.         while queue:
  150.             course = queue.popleft()
  151.             order.append(course)
  152.             course_dependency = dependency_graph[course]
  153.             for d in course_dependency:
  154.                 in_degree_count[d] -= 1
  155.                 if in_degree_count[d] == 0:
  156.                     queue.append(d)
  157.         
  158.         return order if len(order) == numCourses else []
  159. ##################################################################
  160. ### 723. Candy Crush
  161. ##################################################################
  162. class Solution(object):
  163.     def candyCrush(self, board):
  164.         """
  165.         :type board: List[List[int]]
  166.         :rtype: List[List[int]]
  167.         """
  168.         m, n = len(board), len(board[0])
  169.         crush_h = self.check_horizontal(board, m, n)
  170.         crush_v = self.check_vertical(board, m, n)
  171.         while crush_h or crush_v:
  172.             self.drop(board, m, n)
  173.             crush_h = self.check_horizontal(board, m, n)
  174.             crush_v = self.check_vertical(board, m, n)
  175.         return board
  176.    
  177.             
  178.     def drop(self, board, m, n):
  179.         for i in range(n):
  180.             curr = m - 1
  181.             for j in range(m - 1, -1, -1):
  182.                 if board[j][i] > 0:
  183.                     board[curr][i] = board[j][i]
  184.                     curr -= 1
  185.             for k in range(curr + 1):
  186.                 board[k][i] = 0
  187.         
  188.     def check_horizontal(self, board, m, n):
  189.         to_crush = False
  190.         for i in range(m):
  191.             for j in range(n - 2):
  192.                 if abs(board[i][j]) == abs(board[i][j + 1]) == abs(board[i][j + 2]) != 0:
  193.                     board[i][j] = board[i][j + 1] = board[i][j + 2] = -abs(board[i][j])
  194.                     to_crush = True
  195.         return to_crush
  196.         
  197.     def check_vertical(self, board, m, n):
  198.         to_crush = False
  199.         for i in range(n):
  200.             for j in range(m - 2):
  201.                 if abs(board[j][i]) == abs(board[j + 1][i]) == abs(board[j + 2][i]) != 0:
  202.                     board[j][i] = board[j + 1][i] = board[j + 2][i] = -abs(board[j][i])
  203.                     to_crush = True
  204.         return to_crush
  205.         
  206. ##################################################################
  207. ### 348. Design Tic Tac Toe
  208. ##################################################################
  209. # Connect 4
  210. class TicTacToe(object):
  211.     def __init__(self, n):
  212.         self.n = n
  213.         self.rows = [0] * n
  214.         self.cols = [0] * n
  215.         self.diagonal = self.antiDiagonal = 0
  216.    
  217.     def move(self, row, col, player):
  218.         curr_player = 1 if player == 1 else -1
  219.         self.rows[row] += curr_player
  220.         self.cols[col] += curr_player
  221.         if row == col:
  222.             self.diagonal += curr_player
  223.         if row == self.n - col - 1:
  224.             self.antiDiagonal += curr_player
  225.         
  226.         if abs(self.rows[row]) == self.n or \
  227.             abs(self.cols[col]) == self.n or \
  228.             abs(self.diagonal) == self.n or \
  229.             abs(self.antiDiagonal) == self.n:
  230.             return player
  231.         return 0
  232.         
  233. #     def __init__(self, n):
  234. #         self.n = n
  235. #         self.board = [[0 for _ in range(n)] for _ in range(n)]
  236.         

  237. #     def move(self, row, col, player):
  238. #         self.board[row][col] = player
  239.         
  240. #         if self.horizontal_win(row, player) or \
  241. #             self.vertical_win(col, player) or \
  242. #             self.diagonal_inc_win(col, row, player) or \
  243. #             self.diagonal_dec_win(col, row, player):
  244. #             return player
  245. #         return 0
  246.    
  247. #     def horizontal_win(self, row, player):
  248. #         for i in range(self.n):
  249. #             if self.board[row][i] != player:
  250. #                 return False
  251. #         return True
  252.    
  253. #     def vertical_win(self, col, player):
  254. #         for i in range(self.n):
  255. #             if self.board[i][col] != player:
  256. #                 return False
  257. #         return True
  258.    
  259. #     def diagonal_inc_win(self, col, row, player):
  260. #         for i in range(self.n):
  261. #             if self.board[i][i] != player:
  262. #                 return False  
  263. #         return True
  264.    
  265. #     def diagonal_dec_win(self, col, row, player):
  266. #         for i in range(self.n):
  267. #             if self.board[i][self.n - i - 1] != player:
  268. #                 return False  
  269. #         return True

  270. # Your TicTacToe object will be instantiated and called as such:
  271. # obj = TicTacToe(n)
  272. # param_1 = obj.move(row,col,player)
  273.         
  274. ##################################################################
  275. ### 212. Word Search II
  276. ##################################################################
  277. class Solution(object):
  278.     def findWords(self, board, words):
  279.         """
  280.         :type board: List[List[str]]
  281.         :type words: List[str]
  282.         :rtype: List[str]
  283.         """
  284.         def backtracking(i, j, parentNode):
  285.             letter = board[i][j]
  286.             currNode = parentNode[letter]
  287.             
  288.             if "match" in currNode:
  289.                 matched_words.append(currNode["match"])
  290.                 currNode.pop("match")
  291.             
  292.             board[i][j] = "#"
  293.             for x, y in [(1, 0), (-1, 0), (0, 1), (0, -1)]:
  294.                 new_i, new_j = i + x, j + y
  295.                 if new_i < 0 or new_j < 0 or new_i >= m or new_j >= n:
  296.                     continue
  297.                
  298.                 if board[new_i][new_j] not in currNode:
  299.                     continue
  300.                
  301.                 backtracking(new_i, new_j, currNode)
  302.                
  303.             board[i][j] = letter
  304.             
  305.             # optimization: remove leaf node recursively
  306.             if not currNode:
  307.                 parentNode.pop(letter)
  308.             return
  309.         
  310.         
  311.         trie = {}
  312.         for word in words:
  313.             curr = trie
  314.             for w in word:
  315.                 curr[w] = curr.get(w, {})
  316.                 curr = curr[w]
  317.             curr["match"] = word
  318.         
  319.         m, n = len(board), len(board[0])
  320.         matched_words = []
  321.         for i in range(m):
  322.             for j in range(n):
  323.                 if board[i][j] in trie:
  324.                     backtracking(i, j, trie)
  325.                     
  326.         return matched_words
  327. ##################################################################
  328. ### 79. Word Search
  329. ##################################################################
  330. class Solution(object):
  331.     def exist(self, board, word):
  332.         """
  333.         :type board: List[List[str]]
  334.         :type word: str
  335.         :rtype: bool
  336.         """
  337.         def backtracking(x, y, index):
  338.             if index == len(word) - 1:
  339.                 return True

  340.             board[x][y] = "#"
  341.             for x_offset, y_offset in [(0, 1), (0, -1), (1, 0), (-1, 0)]:
  342.                 new_x, new_y = x + x_offset, y + y_offset
  343.                 if new_x < 0 or new_y < 0 or new_x >= m or new_y >= n \
  344.                     or board[new_x][new_y] != word[index + 1]:
  345.                     continue
  346.                 if backtracking(new_x, new_y, index + 1):
  347.                     return True
  348.             board[x][y] = word[index]
  349.             return False
  350.    
  351.    
  352.         m, n = len(board), len(board[0])
  353.         for i in range(m):
  354.             for j in range(n):
  355.                 if board[i][j] == word[0] and backtracking(i, j, 0):
  356.                     return True
  357.         return False

  358. ##################################################################
  359. ### 981. Time Based Key-Value Store
  360. ##################################################################
  361. from sortedcontainers import SortedDict

  362. class TimeMap(object):

  363.     def __init__(self):
  364.         self.kv_map = {}

  365.     def set(self, key, value, timestamp):
  366.         """
  367.         :type key: str
  368.         :type value: str
  369.         :type timestamp: int
  370.         :rtype: None
  371.         """
  372.         if key not in self.kv_map:
  373.             self.kv_map[key] = SortedDict()
  374.         self.kv_map[key][timestamp] = value

  375.     def get(self, key, timestamp):
  376.         """
  377.         :type key: str
  378.         :type timestamp: int
  379.         :rtype: str
  380.         """
  381.         if key not in self.kv_map:
  382.             return ""
  383.         
  384.         idx = self.kv_map[key].bisect_right(timestamp)
  385.         return "" if idx == 0 else self.kv_map[key].peekitem(idx - 1)[1]


  386. # Your TimeMap object will be instantiated and called as such:
  387. # obj = TimeMap()
  388. # obj.set(key,value,timestamp)
  389. # param_2 = obj.get(key,timestamp)

  390. ##################################################################
  391. ### Key-Value Store w/ Transactions
  392. ##################################################################
  393. # GlobalStore is a map which is shared by all the transactions in the stack.
  394. # This is how we achieve a parent-child relationship

  395. from collections import deque

  396. class KVStore(object):

  397.     def __init__(self):
  398.         self.stack = deque([{}])

  399.     def set(self, key, val):
  400.         if len(self.stack) == 0:
  401.             self.stack.append({})
  402.         self.stack[-1][key] = val

  403.     def get(self, key):
  404.         for i in range(len(self.stack) -  1, -1, -1):
  405.             if key in self.stack[i]:
  406.                 return self.stack[i][key]
  407.         return ""

  408.     def delete(self, key):
  409.         # ?
  410.         if len(self.stack) > 0:
  411.             self.stack[-1][key] = None

  412.     def begin(self):
  413.         curr_snapshot = {}
  414.         self.stack.append(curr_snapshot)

  415.     def commit(self):
  416.         #?
  417.         last_dic = self.stack.pop()
  418.         for k, v in last_dic.items():
  419.             self.stack[-1][k] = v

  420.         # ??
  421.         # curr_snapshot = {}
  422.         # self.stack.append(curr_snapshot)

  423.     def rollback(self):
  424.         if len(self.stack) > 0:
  425.             self.stack.pop()


  426. ##################################################################
  427. ### 162. Find Peak Element (One)
  428. ##################################################################
  429. class Solution(object):
  430.     def findPeakElement(self, nums):
  431.         """
  432.         :type nums: List[int]
  433.         :rtype: int
  434.         """
  435.         l, r = 0, len(nums) - 1
  436.         while l < r:
  437.             mid = (l + r) / 2
  438.             if nums[mid] > nums[mid + 1]:
  439.                 r = mid
  440.             else:
  441.                 l = mid + 1
  442.         return l

  443. ##################################################################
  444. ### 162. Find Peak Element (All)
  445. ##################################################################
  446. class Solution(object):
  447.     # front, end?
  448.     # duplicate?
  449.     def findAllPeakElement(self, nums):
  450.         if len(nums) <= 1:
  451.             return nums

  452.         result = []
  453.         for i in range(len(nums)):
  454.             if i == 0:
  455.                 if nums[i + 1] < nums[i]:
  456.                     result.append(num[i])
  457.             elif i == len(nums) - 1:
  458.                 if nums[i - 1] < nums[i]:
  459.                     result.append(nums[i])
  460.             else:
  461.                 if nums[i - 1] < nums[i] > nums[i + 1]:
  462.                     result.append(nums[i])

  463.         return result

  464.     # with duplicate
  465.     def findAllPeakElementWithDuplicate(nums):
  466.         if len(nums) <= 1:
  467.             return nums

  468.         unique_nums = []
  469.         curr, count = nums[0], 1
  470.         for i in range(1, len(nums)):
  471.             if nums[i] == curr:
  472.                 count += 1
  473.             else:
  474.                 unique_nums.append((curr, count))
  475.                 curr, count = nums[i], 1
  476.         unique_nums.append((curr, count))

  477.         if len(unique_nums) == 1:
  478.             return [unique_nums[0][0]] * unique_nums[0][1]

  479.         result = []
  480.         for j in range(len(unique_nums)):
  481.             if j == 0:
  482.                 if unique_nums[j + 1][0] < unique_nums[j][0]:
  483.                     result += [unique_nums[j][0]] * unique_nums[j][1]
  484.             elif j == len(unique_nums) - 1:
  485.                 if unique_nums[j - 1][0] < unique_nums[j][0]:
  486.                     result += [unique_nums[j][0]] * unique_nums[j][1]
  487.             else:
  488.                 if unique_nums[j - 1][0] < unique_nums[j][0] > unique_nums[j + 1][0]:
  489.                     result += [unique_nums[j][0]] * unique_nums[j][1]
  490.         return result
  491. ##################################################################
  492. ### Top Game
  493. ##################################################################
  494. # dict = {"user1": [(1001, xxxxx, join), (1001, xxxxxxxx, quit)],
  495. #         "user2": []}
  496. def topGame(logs):
  497.     user_game_map = defaultdict(list)
  498.     for l in logs:
  499.         time, user, game, action = l.split(",")
  500.         user_game_map.append((game, time))

  501.     game_map = defaultdict(int)
  502.     for user, game_events in user_game_map.items():
  503.         curr_time = curr_count = 0
  504.         games_to_estimate = []

  505.         l = 0
  506.         while l < len(game_events):
  507.             if game_events[l][2] == "join":
  508.                 if l == len(game_events) - 1 or game_events[l + 1][2] == "join":
  509.                     games_to_estimate.append(l)
  510.                     l += 1
  511.                 else:
  512.                     if game_events[l][0] == game_events[l + 1][0]:
  513.                         curr_count += 1
  514.                         curr_time += game_events[l + 1][1] - game_events[l][1]
  515.                         game_map[game_events[l][0]] += game_events[l + 1][1] - game_events[l][1]
  516.                         l += 2

  517.         avg = float(curr_time) / float(curr_count)
  518.         for index in games_to_estimate:
  519.             # grab next event from game_events
  520.             # find min of avg and next event time
  521.             # add it to game_map

  522.         return max in game_map


  523. # dict = {"1001": {"user1": (0, 10), "user2": (0, 5)},
  524. #         "1002": {"user1": (0, 15), "user3": (0, 5)},""}
  525. def topGame(logs):
  526.     game_user_map = {}
  527.     for l in logs:
  528.         time, user, game, action = l.split(",")
  529.         if game not in game_user_map:
  530.             game_user_map[game] = {}

  531.         if user not in game_user_map[game]:
  532.             game_user_map[game][user] = (-1, 0)

  533.         last_timestamp, total_time = game_user_map[game][user]
  534.         if action == "join":
  535.             last_timestamp = time
  536.         else:
  537.             last_timestamp = -1
  538.             total_time += time - last_timestamp

  539.         game_user_map[game][user] = (last_timestamp, total_time)


  540.     top_game, max_time = None, -float("inf")
  541.     for game, user_map in game_user_map.items():
  542.         curr_time = 0
  543.         for user_time in user_map.values():
  544.             curr_time += user_time[1]

  545.         if curr_time > max_time:
  546.             top_game = game
  547.             max_time = curr_time

  548.     return top_game

  549. ##################################################################
  550. ### 1472. Design Browser History
  551. ##################################################################
  552. from collections import deque

  553. class BrowserHistory(object):

  554.     def __init__(self, homepage):
  555.         self.history = deque()
  556.         self.history.append(homepage)
  557.         self.curr_index = 0
  558.         

  559.     def visit(self, url):
  560.         while len(self.history) > self.curr_index + 1:
  561.             self.history.pop()
  562.         
  563.         self.history.append(url)
  564.         self.curr_index = len(self.history) - 1
  565.         
  566.     def back(self, steps):
  567.         while steps > 0 and self.curr_index > 0:
  568.             self.curr_index -= 1
  569.             steps -= 1
  570.             
  571.         return self.history[self.curr_index]

  572.     def forward(self, steps):
  573.         while self.curr_index < (len(self.history) - 1) and steps > 0:
  574.             self.curr_index += 1
  575.             steps -= 1
  576.         return self.history[self.curr_index]
  577.         
  578. # multi-tab: 写一个新的class去实现openTab,和closeTab
  579. # Your BrowserHistory object will be instantiated and called as such:
  580. # obj = BrowserHistory(homepage)
  581. # obj.visit(url)
  582. # param_2 = obj.back(steps)
  583. # param_3 = obj.forward(steps)

  584. ##################################################################
  585. ### 33. Search in Rotated Sorted Array
  586. ##################################################################
  587. class Solution(object):
  588.     def search(self, nums, target):
  589.         """
  590.         :type nums: List[int]
  591.         :type target: int
  592.         :rtype: int
  593.         """
  594.         l, r = 0, len(nums) - 1
  595.         while l <= r:
  596.             mid = l + (r - l) // 2
  597.             if nums[mid] == target:
  598.                 return mid
  599.             elif nums[mid] >= nums[l]:
  600.                 if nums[l] <= target < nums[mid]:
  601.                     r = mid - 1
  602.                 else:
  603.                     l = mid + 1
  604.             else:
  605.                 if nums[mid] < target <= nums[r]:
  606.                     l = mid + 1
  607.                 else:
  608.                     r = mid - 1
  609.         
  610.         return -1
复制代码
SD
- Design一个fraud侦测service
- 通过run model来说一个user是不是fraud
- Collaborative TODO list
- 要求能handle concurrent editing
- 允许users相互share,共同编辑
- The application should allow a single user or team of users to keep track of a list of tasks to do in the
future. Example:
- 1. John creates a list named "Grocery shopping list”
- 2. John adds task Buy Tomatoes to Grocery Shopping List
- 3. John adds task Buy Onions to Grocery Shopping List
- 4. John completes task Buy Onions from Grocery Shopping List
- 5. John has 1 TODO list with 2 tasks B
- 设计一个checklist application,可以允许多人share并协同工作,需要支持:添加list,添加
item,删除item,标记完成,分享list。考察的比较细致,data model, api design, protocol,
scalability都有考察到,甚至还写了点sql —
thread-899276-1-1.html
- On top of managing todo lists the application should allow collaboration of multiple users on
individual todo lists. Example
- 1. John has 1 TODO list with 2 tasks
- 2. John shares Grocery shopping list with Maria
- 3. Maria adds task Buy Oranges to Grocery shopping list
- 4. Maria completes task Buy Tomatoes from Grocery shopping list
- Design a collaborative to-do list application. 大体要求是多人可以在同一个to-do list里面add
task,或者complete task。其次是不同人有不同的role,从基础的viewer(可以增加或者完成
task),到editor(可以改task名字什么的),到admin(可以创建删除todo list之类的)。讨论
内容有API, data model, database选择,如何把某个client的改动及时同步到别的clients里
面,
一个todo list里面collaborator太多读写流量太大怎么办之类的。
- shared links per 5 min, 1 hour, 24 hours,qps很高。刚开始用heap,后来改用ring buffer做的,但
是俄罗斯面试官几乎在我每说一句话都会问‍ ‌‌‍‌‌‌‍‌‍‌‌‍‍‍‍‍‍ 各种问题,比方da
您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
使用VIP即刻解锁阅读权限或查看其他获取积分的方式
游客,您好!
本帖隐藏的内容需要积分高于 188 才可浏览
您当前积分为 0。
VIP即刻解锁阅读权限查看其他获取积分的方式
Unlock interview details and practice with AI
Curated Interview Questions from Top Companies

的作者。所以会产生一些输入[{user1, pay amount:$100, time: 15:00}, {user2, pay amount:$50,
time: 16:00}...]。按照面试官的意思,要求是payment在指定时间的几分钟之内发生吧,如果
出错了要像个办法处理
- Design payment system
- 设计一个payment hold的系统。这个其他面筋也提到过,讲一下其他面筋都没有提到的问
题。第一:QPS 5K, 第二:这个系统需要直接cancel payment。这个就需要确定payment
hold API的返回值是什么,如果用了卡夫卡做缓冲会怎么样,NO SQL怎么做sharding等等,
这个地方我答的不太好,很可能就是挂在这里,希望可以帮到后来人。另外也问了一下
payment system怎么跟payment hold配合工作的,需要讲一下payment system的workflow和
DB。
- 设计一个delay transcation system,背景是他们自己的game platform里面的虚拟货币,要求用
户可以设定一个未来的时间来给另一个用户转特定数额的钱,并可以支持cancel还未发生的
transactions,可以assume有一个banking API可以call去真正执行transaction。
- Design a payment scheduling system. 主要要求是可以允许Roblox玩家说给另一个玩家转一定数
量的游戏币,不过要在指定是时间点转(比如3天后,2小时后之类的),然后不用考虑
payment system本身的设计,就假设有个现成的payment API。大方向上像个delayed job
scheduling system,不过有一些特别的细节:(1)发起转账的用户里面的钱得立马扣下;
(2)指定的未来时间可以是10几秒之后,所以定时polling的系统是不行的;(3)发给接收
方的钱的操作可能会有不可重试的错误,比如接收方账户因为用外挂被注销了什么的,所以
其实整个系统其实是个transaction系统,要考虑rollback,以及常见的WAL之类的手段来达到
durability要求。面试官还粗略问了一些API design(REST vs RPC),API security,
notification,idempotency(payment)相关的内容。

本帖子中包含更多资源

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

x

评分

参与人数 35大米 +66 收起 理由
luiance + 1 给你点个赞!
aersd + 1 很有用的信息!
rollothomasi + 1 赞一个
Russelluo + 1 给你点个赞!
ainiyouyou + 1 赞一个

查看全部评分


上一篇:Jane Street QT Trading Intern On-site
下一篇:求问 Apple Safari and WebKit Security & Privacy 面经
推荐
WaynePai 2024-1-24 00:32:42 | 只看该作者
全局:
好人一生平安
回复

使用道具 举报

地里匿名用户
推荐
匿名用户-X2UOH  2023-12-8 13:02:25

哦哦 感觉他家coding题目看来没有特别多的样子,多谢楼主!
回复

使用道具 举报

🔗
spongeFox 2023-11-16 05:52:01 | 只看该作者
全局:
感謝樓主!
回复

使用道具 举报

🔗
pumazda 2023-11-17 02:39:49 | 只看该作者
全局:
好人一生平安
回复

使用道具 举报

全局:
好人一生平安!!
回复

使用道具 举报

🔗
turbo0428 2023-12-1 14:06:49 | 只看该作者
全局:
好人一生平安!!
回复

使用道具 举报

地里匿名用户
🔗
匿名用户-X2UOH  2023-12-8 04:23:24
已加米! 请问楼主coding是只是店面吗 还是包含了onsite的?谢谢呀
回复

使用道具 举报

地里匿名用户
🔗
匿名用户-FZMAO  2023-12-8 04:41:50
好人一生平安!!
回复

使用道具 举报

地里匿名用户
🔗
匿名用户-5874P  2023-12-8 12:24:16 来自APP
匿名用户 发表于 2023-12-07 12:23:24
已加米! 请问楼主coding是只是店面吗 还是包含了onsite的?谢谢呀
包含了onsite
回复

使用道具 举报

地里匿名用户
🔗
匿名用户-X2UOH  2023-12-10 02:50:52
还想请问一下楼主 老看到的karat 面试是什么呀,是针对某些特定职位么,现在是否取消了呢?谢谢!
回复

使用道具 举报

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

本版积分规则

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