Guest User

Untitled

a guest
Feb 18th, 2020
436
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.57 KB | None | 0 0
  1. Uber Onsite
  2. 1 Behavior + 2 System Design Or 1 System Design and 1 Bar raiser behavior questions + 2 Coding
  3. Behavior
  4. HM: Talk about your projects
  5. Bar Raiser: All behavior questions like how to handle conflict/Disagreement with manager, your experience about coordination with other teams. There’s an interesting one: if you left your job, what about you that you think your manager won’t miss you most?
  6.  
  7.  
  8. System Design
  9. 1. (High frequent) Design an uber feature which notifies drivers for the riders.
  10. Interviewer will have a paper with 2 requirements:
  11. Display the density of cars in the current area real time ( heatmap )
  12. Able to read history hourly or daily/ read history in the last 20 mins and last 24 hours
  13. Optional: draw heatmap UI
  14. Similar ones: How to match drivers and riders? (map geo index)
  15. Note 1: The poster discussed what servers the system needs, how to use them to pass data, how to display data in front end, how to store data in database.
  16. Note 2: heatmap + LB strategies + nosql vs sql + diff between memcached and redis + implement a cache with LRU (pseudo code) + cache use strategy
  17. Note 3: Look up Uber engineer’s blog online.
  18. Resource:
  19. https://myslide.cn/slides/2891#
  20.  
  21. 2. (High frequent) Design Messager/whatsapp/Uber in-app chat/ slack
  22.  
  23. 3. (High frequent) Draw architect of your projects and explain it./ The interviewer gives you an architect graph, you talk about how to design log / metrics system based on the given architect so that the system can record data for future analytics purposes.
  24.  
  25. 4.(Medium frequent) Design stock trade system. Resource: Look up data-intensive applications system design online
  26.  
  27. 5.Design a uber feature to warn drive about long time drive + design a generic scheduling service.
  28.  
  29. 6.Design a system that users can update and share real time location to friends and multiple friends can subscribe to that user.
  30. 7.Design time series db.
  31. Resource: Read about uber’s own time series db https://m3db.github.io/m3/m3db/
  32.  
  33. 8.Design an online photo upload system, for example, upload 5 small photos via phone, how does backend combine 5 small ones to a big one ( No need to design the photo combination implementation itself, assume you have a library to do so). How to scale this system?
  34.  
  35. 9. Design twitter
  36.  
  37. 10. Design Short URL for twitter
  38. Interviewer’s possible questions:
  39. What database are you gonna use to store data? How to add index, why can index fasten read speed of database?
  40. If there’s huge traffic to system, how will you scale? DB sharding, cache server, local cache on web server,load balancer for web server
  41. Is there consistency problem for local cache?
  42. If the owner who generated that short url can delete it, how to modify the design system? How to design the delete API?
  43.  
  44. 11.Design battle ship game. Two players, each one has a few ships on the board, ships’ positions are fixed. Each player can only see his own board, can’t see the other person’s and don’t know ships positions from the other player. Each player takes turns to fire to a coordination. If hit, that mark the hit ship position and the fire position for future reference. Ship can only be placed vertically or horizontally.
  45. Follow ups:
  46. If the game is not local, it is for 2 ppl online.
  47. How to look up quickly about which ship is hit from the fire coordination. The poster said binary search rows and columns, time complexity is O(logn), then interviewer asked if we don’t worry about memory usage, can it be faster? The poster said record the coordination of all ships, then it’s O(1), the interviewed said bingo...
  48.  
  49. 12. (Identity and secret storage team) Design authentication system to add user, authenticate user, get user’s profile and log out user.
  50.  
  51. Questionable ones:
  52. 13. Design 秒杀系统 (I don’t know wtf is this, I’ll come back later)
  53. 14. Merge SQL rows. Solution: use union find.
  54. Coding
  55. LC Questions:
  56. 139/140: Word break I and II (High frequent)
  57. 465 (High frequent)
  58. 21: Merge Two Sorted Lists
  59. 449: serialize/deserialize binary tree https://leetcode.com/problems/serialize-and-deserialize-bst
  60. Follow up: serialize/deserialize n tree
  61.  
  62. 621: https://leetcode.com/problems/task-scheduler
  63.  
  64. 267: https://leetcode.com/problems/palindrome-permutation-ii
  65.  
  66. 218: https://leetcode.com/problems/the-skyline-problem
  67.  
  68. longest substring with at most k distinct characters
  69.  
  70. Coding: Given a treeNode in a binary tree, find all nodes that are K distance away from this tree node.
  71.  
  72. Coding: Twist of classic number of island question. All positions are water (0), no island (1) at first, implement a function that input is a coordination, purpose is to put an island in the given coordination, output is the number of island now. Every time after the function is called, the number of islands can be more/less/equal because islands could be connected.
  73. Similar one: Minesweep
  74.  
  75. Coding:Given a 2D array, each element means car or empty spot, return the distance from each element in the array to the closest car. Might be a leetcode question.
  76.  
  77. Coding: input is a few intervals, find overlapped intervals.
  78. Follow up: Some of them is not overlapped, some of them 2 times, 3 times, return intervals that are overlapped moe than K times
  79.  
  80. Coding: return all valid partitioned palindrome for a string + return the valid palindrome list with smallest partitions
  81.  
  82. Coding: Students has prefer list to apply colleges, colleges has prefer list for students, how to allocate students to colleges. Students’ preference takes higher priority. The core part is to check if there is conflict in different students’ preferences. If there is, see which student is in the higher priority list from college’s prefer list. If there is no conflict, even if the student is not on school’s prefer list, the student can still get in. Possible solution: use map.
  83.  
  84. Coding: Parse CSV. (Says high frequency, not sure the real question though)
  85. Similar one: Use JS to parse input JSON.
  86.  
  87.  
  88. Coding: Given 2 numbers num1 and num2, return result of num1/num2, e.g. if 1/2, return 0.5, if 1/3 whose result has repeat numbers 0.333333333333333, use braces () for repeat digits, I guess return 0.(3)
  89.  
  90. Coding: input is a string, print all palindromes that can be formed by using all characters in the string, if can’t form any palindrome, print []. ???
  91.  
  92. Coding: Given a 2d board like Tetris with width n, blocks fall into the bottom. The definition of blocks are:
  93. class Block {
  94. int left;
  95. int right;
  96. int height;
  97. }
  98. 0<= left < right < n, blocks will be built up one on top of the other like Tetris, return the maximum height.
  99. class FallingBlock {
  100. public FallingBlock(int width);
  101. public void fallBlock(Block block);
  102. public int getMaxHeight();
  103. }
  104.  
  105.  
  106. Possible solution 1 (I don’t understand what this person is talking):
  107. Use height[width] and maxHeight. Every time when a block is placed, find the max height h from left to right and then update the height to h+block’s height, if it’s higher than current maxHeight, update it.
  108.  
  109. Possible solution 2:
  110. public class FallingBlock {
  111.  
  112. static class Block {
  113. int left;
  114. int right;
  115. int height;
  116.  
  117. public Block(int left, int right, int height) {
  118. this.left = left;
  119. this.right = right;
  120. this.height = height;
  121. }
  122. }
  123.  
  124. private int boardWidth;
  125. int[] heights;
  126.  
  127. // width is the board width
  128. public FallingBlock(int width) {
  129. // Height of segment tree
  130. int x = (int) (Math.ceil(Math.log(width) / Math.log(2)));
  131. // Maximum size of segment tree
  132. int maxSize = 2 * (int) Math.pow(2, x) - 1;
  133. heights = new int[maxSize]; // Memory allocation
  134. boardWidth = width;
  135. }
  136.  
  137. public void fallBlock(Block block) throws IllegalArgumentException {
  138. fallBlockInternal(block, 0, boardWidth - 1, 0);
  139. }
  140.  
  141.  
  142. public int fallBlockInternal(Block block, int start, int end, int index) {
  143. // haven't init this segment yet
  144. if (heights[index] == 0) heights[index] = heights[(index - 1) / 2];
  145.  
  146. if (start >= block.left && start <= block.right) {
  147. // If segment of this node is a part of given range, then
  148. heights[index] += block.height;
  149. // System.out.println("start:" + start + " end:" + end + " index:" + index + " height:" + heights[index]);
  150. return heights[index];
  151. } else if (start > block.right || end < block.left) {
  152. // If segment of this node is outside the given range
  153. // System.out.println("start:" + start + " end:" + end + " index:" + index + " height:" + heights[index]);
  154. return heights[index];
  155. } else {
  156. // If a part of this segment overlaps with the given range
  157. int mid = (start + end) >>> 1;
  158. heights[index] = Math.max(
  159. fallBlockInternal(block, start, mid, index * 2 + 1),
  160. fallBlockInternal(block, mid + 1, end, index * 2 + 2));
  161. // System.out.println("start:" + start + " end:" + end + " index:" + index + " height:" + heights[index]);
  162. return heights[index];
  163. }
  164. }
  165.  
  166. public int getMaxHeight() {
  167. return heights[0];
  168. }
  169.  
  170. public static void main(String[] args) throws Exception {
  171. FallingBlock fallingBlock = new FallingBlock(100);
  172. fallingBlock.fallBlock(new Block(20, 50, 1));
  173. fallingBlock.fallBlock(new Block(30, 70, 2));
  174. fallingBlock.fallBlock(new Block(10, 40, 3));
  175. // fallingBlock.fallBlock(new Block(80, 90, 10));
  176.  
  177. System.out.println("max height is " + fallingBlock.getMaxHeight());
  178. }
  179.  
  180. }
Add Comment
Please, Sign In to add comment