Dropbox计算机科学面试真题

职位分类
全部
数据相关
计算机科学
人工智能
产品经理
BQ
面试题
全部(90)
OOD(14)
Algorithm(25)
System Design(43)
高频题(0)
Math(0)
全部(90)
OOD(14)
Algorithm(25)
System Design(43)
高频题(0)
Math(0)
1.Rotate Image by 90 Degrees In-Place
2.设计in-memory database
3.File System
4.Dom tree
5.Implement text editor(2)
6.Implement text editor(1)
7.Conway's Game of Life: Next State Calculation
8.In-Memory Database Design
9.Matrix Rotation and Reflection
10.Array Cyclic Shift Sorting
11.Robot Command Cyclic Shift
12.Design a File Search System
13.In-Memory Database Implementation
14.In-Memory Database System Modifications
15.Design a Producer-Consumer System
16.Design a Key-Value Store with Read Committed Isolation Level
17.Implement a Top N Photo Views Feature
18.Debugging a TODO List
19.File Explorer Component Implementation
20.System Design for Google Calendar
21.File System Design
22.Technical Problem: Allocate ID
23.Code Review Process
24.Concurrency/Multithreading in Coding Interviews
25.In-Memory OOD Problem
26.Allocate ID
27.Duplicate Files
28.Implement a Simple Version of a Text Editor
29.Allocate ID Optimization
30.Optimize Online Grocery App Checkout Code
31.Design a Cloud Storage System
32.Code Review Exercise
33.Island Problem Variation
34.Design a Cloud Storage System
35.Thread-safe Counter Increment
36.Count Set Bits in Binary Representation
37.Log File Information Retrieval
38.Supermarket System Code Review
39.Island Problem
40.Deep Dive into a Project
41.Code Review - Supermarket Checkout System
42.Recommendation System Design
43.Island Problem - Maximum Island
44.Minimize Graph Diameter with K Leaf Removals
45.Design a Bank System
46.Banking System Implementation
47.Minimum Difference in a Matrix with Distance Constraint
48.Matrix Blur
49.Replace Non-Vowel Characters in a String
50.Implement Backup and Restore with TTL and Timestamps
51.Enhance Database Operations with Timestamps and TTL
52.Implement Scan Operations with Prefix Matching
53.Implement Basic Operations for In-Memory Database
54.Design a Worker Time Tracking System
55.Design a Simplified In-Memory Database
56.Logging System Design
57.File Crawler Optimization
58.Design a Chessboard with New Rules
59.Implement a Token Bucket Algorithm
60.Implement a Web Crawler
61.Design a Transaction System for a Key-Value Store
62.Asynchronous File Crawling Module
63.Guess the Word Game Strategy
64.Design a Course Registration System
65.Design a Simplified College Course Enrollment System
66.Implement the 'promote' and 'calculate' methods for a worker information system
67.Design a Schedule Payment Function
68.Implement a Top Spender Function
69.Design a Banking System
70.In-Memory Database Operations
71.Account Merge and Balance Query at a Specific Time
72.Implement Cashback with Timestamps
73.Object-Oriented Design for Custom Chess Game
74.Algorithm for Processing Data in a Stream
75.System Design for File Listing on Homepage
76.Implement Scoring Functionality in a Course Registration System
77.Find All Student Pairs Registered in the Same Course
78.Design a Course Registration System
79.Get Pairs Function
80.Create Course and Register for Course Functions
81.Find Top K Files in a File System
82.Distributed Count of Page Visits
83.Thread-safe Count of Page Visits
84.Count Set Bits in an Integer
85.Search for Errors in Log Files
86.System Design: Logging System
87.Hangman Game Coding Challenge
88.File Crawler Implementation
89.Design a File Management System
90.Design a Bank System
1. Rotate Image by 90 Degrees In-Place
You are given an n x n 2D matrix representing an image, rotate the image by 90 degrees (clockwise).

You have to rotate the image in-place, which means you have to modify the input 2D matrix directly. DO NOT allocate another 2D matrix and do the rotation.

 

Example 1:

Input: matrix = [[1,2,3],[4,5,6],[7,8,9]]
Output: [[7,4,1],[8,5,2],[9,6,3]]

Example 2:

Input: matrix = [[5,1,9,11],[2,4,8,10],[13,3,6,7],[15,14,12,16]]
Output: [[15,13,2,5],[14,3,4,1],[12,6,8,9],[16,7,10,11]]

 

Constraints:

  • n == matrix.length == matrix[i].length
  • 1 <= n <= 20
  • -1000 <= matrix[i][j] <= 1000
2. 设计in-memory database
 | 设计in-memory database,一共4个level,所有test都过才能解锁下一个level。level 1是要写set,get 和delete三个func:
 set:["SET","A","B","5"],return "5"; database: {"A":{"B":"5"}};
 set:["SET""A","B","6"],return "11",database:{"A":{"B":11"}};如果data已经在database里的话要加之前的value;
 set:["SET","A","C","1"],return "1"; database:{"A":{"B":"11","C":"1"}}
 
 get就是value,没有在database里的话返回“”;
 delete是删除给定的field
 如果database里面没有field了,这个database也要删除掉
 get就是value,没有在database里的话返回"";
 delete是删除给定的field,如果database里面没有field了,这个database好像也要删除掉
 level2是写TOPNKEYS,返回最新编过过的N个file。
 level3 写users,不同user的database也不一样
 level 4是undo和logout
3. File System
一个file system,如果parent有access的话child file 也有access。给了input是

1.array representing child to parent relationship, 

2. a set contains all the files have access. 问一个hasAccess(String fileName) API。建好hashmap就很顺利做完,trick是从child往parent/root方向看。


Follow up是remove redundant access,比如说下面的example,如果file1, file2, file3 都有access,我们就把原先input的那个set只保留file1
 
FILE1 -‍‍‌‌‌‌‍‍‍‍‍‌‌‌‌‍‍‌‍‌> File2
 
|
 
- ---> File3
4. Dom tree
Given a DOM tree, implement two functions. 

1. getNodeByClassName

 2. getNodeByClassNameHierarchy 给你一个root node和 string代表的css classname, 从树中找出符合classname的target node
5. Implement text editor(2)
写一个text editor, 有append, move, backspace, select,copy paste等功能
Level 3
 
The text editor should allow document changes to be tracked and reverted. Consider only operations that actually modify the contents of the text document, which are (APPEND, BACKSPACE, PASTE, UNDO, and REDO).
 
1. UNDO should restore the document to the state before the previous modification or REDO operation. The selection and cursor position should be also restored.
 
For example,
 
queries = [
 
["APPEND", "Hello, world!"], | "" -> "Hello, world!"
 
["SELECT", "7", "12"], | selects "world"
 
["BACKSPACE"], | "Hello, world!" -> "Hello, !"
 
["UNDO"], | restores "Hello, world!" with "world" selected
 
["APPEND", "you"] | "Hello, world!" -> "Hello, you!"
 
]
 
// returns: [ "Hello, world!",
 
// "Hello, world!",
 
// "Hello, !",
 
// "Hello, world!",
 
// "Hello, you!" ]
 
2. REDO can only be performed if the document has not been modified since the last UNDO operation. REDO should restore the state before the previous UNDO operation, including the selection and cursor position. Multiple UNDO and REDO operations can be performed in a row.
 
For example,
 
queries = [
 
["APPEND", "Hello, world!"], | "" -> "Hello, world!"
 
["SELECT", "7", "12"], | selects "world"
 
["BACKSPACE"], | "Hello, world!" -> "Hello, !"
 
["MOVE", "6"], | moves the cursor to after the comma
 
["UNDO"], | restores "Hello, world!" with "world" selected
 
["UNDO"], | restores initial ""
 
["REDO"], | restores "Hello, world!" with "world" selected
 
["REDO"] | restores "Hello, !" with the cursor after the comma
 
]
 
// returns: [ "Hello, world!",
 
// "Hello, world!",
 
// "Hello, !",
 
// "Hello, !",
 
// "Hello, world!",
 
// "",
 
// "Hello, world!",
 
// "Hello, !" ]

Level 4
 
The text editor should support multiple text documents with a‍‍‌‌‌‌‍‍‍‍‍‌‌‌‌‍‍‌‍‌ common clipboard.
 
1. CREATE <name> should create a blank text document name. If such a file already exists, ignore the operation and return empty string. Modification history is stored individually for each document.
 
2. SWITCH <name> should switch the current document to name. If there is no such file, ignore the operation and return empty string. When switching to a file, the position of the cursor and selection should return to the state in which they were left.
 
Note: it is guaranteed that all operations from previous levels will be executed on the active document. For backward compatibility, assume for Levels 1-3 there is a single, initially active document.
 
For example,
 
queries = [
 
["CREATE", "document1"], | creates document1
 
["CREATE", "document2"], | creates document2
 
["CREATE", "document1"], | ignores the operation
 
["SWITCH", "document1"], | switches to document1
 
["APPEND", "Hello, world!"], | document1: "" -> "Hello, world!"
 
["SELECT", "7", "12"], | selects "world"
 
["COPY"], | copies "world" to the clipboard
 
["SWITCH", "document2"], | switches to document2
 
["PASTE"], | document2: "" -> "world"
 
["SWITCH", "document1"], | switches to document1
 
["BACKSPACE"] | document1: "Hello, world!" -> "Hello, !"
 
]
 
// returns: [ "",
 
// "",
 
// "",
 
// "",
 
// "Hello, world!",
 
// "Hello, world!",
 
// "Hello, world!",
 
// "",
 
// "world",
 
// "Hello, world!",
 
// "Hello, !" ]
 
Example
 
For
 
queries = [
 
["APPEND", "Hey"],
 
["APPEND", " you"],
 
["APPEND", ", don't"],
 
["APPEND", " "],
 
["APPEND", "let me down"]
 
]
 
the output should be
 
textEditor2_2(queries) = [
 
"Hey",
 
"Hey you",
 
"Hey you, don't",
 
"Hey you, don't ",
 
"Hey you, don't let me down"
 
]