Databricks计算机科学面试真题

职位分类
全部
数据相关
计算机科学
人工智能
产品经理
BQ
面试题
全部(85)
OOD(5)
Algorithm(43)
System Design(25)
高频题(0)
Math(0)
全部(85)
OOD(5)
Algorithm(43)
System Design(25)
高频题(0)
Math(0)
1.lazy array
2.Design WebCrawler
3.check obstacles
4.设计total revenue系统
5.求figure掉下来之后的board状态
6.最便宜的车票
7.string formatting
8.Design a stock buy/sell exchange system
9.设计一个mockHashMap
10.计算所有后缀pair的个数
11.重新排版字符串
12.判断单调递增/递减
13.实现一个迭代器
14.实现lazy array
15.shortest distance II
16.Time-Based Key-Value Store Design
17.RemoveCommentsFromCPPCode
18.String changable
19.SnapshotSet
20.StringBuilder
21.Merge k Sorted Lists
22.Common ancestor
23.List of coordinates
24.Text editor
25.Class
26.Root url
27.Minimum Missing Positive Integer in Submatrices
28.Array Rearrangement to Descending Order
29.Character Connection in Array
30.Counting 1s in a Binary String
31.CamelCase Conversion in a String
32.Reformat a String by Alternating Characters
33.Range Frequency Queries Optimization
34.Bubble Pop Game Matrix Operation
35.String Splitting Problem
36.String Transformation Based on Adjacent List Items
37.Web Crawler System Design
38.Map Walking Optimization
39.Map Walking Optimization
40.Find Shift Amount for Sorted Array
41.Rearrange Array Elements
42.Implement a Variant of Tic Tac Toe
43.Graph Merging with Randomness
44.Design a SnapshotSet Interface
45.String Pattern Matching
46.Implement and Test a LazyArray
47.Design a Distributed File System
48.Design a Single-Machine Key-Value Store
49.Identify Bottleneck Nodes in a Directed Graph
50.Design a system to get the lowest k customers by total revenue exceeding a threshold
51.Bubble Operations on a 2D Matrix
52.Substring Splitting Based on Array Index
53.Design a Credit Card Authorization System
54.Longest Continuous Subarray with Limited Difference
55.Find Local Maxima in a Matrix
56.Pattern Matching in a Digit-Only String
57.Find the Index of the First Local Minimum in an Array
58.Find the Index of the First Element Smaller Than Its Neighbors
59.Find the Index of the First Element Smaller Than Its Neighbors
60.Number Pairs with Single Digit Difference
61.Array Cycle Sorting
62.Prefix Sum Problem
63.Design Customer Revenue Tracking System with Referral Feature
64.Balloon Popping
65.Count Matching Subsequences
66.Design a Collaborative Music Playlist System
67.Design a VISA Settlement System
68.Design a Stock Trading System
69.Tic Tac Toe Game Coding
70.Multi-thread Web Crawler
71.Systems Architecture for a Trading System
72.Design a Visa Network
73.Prefix Pair Count in a String Array
74.Memory Allocation and Erasure Simulation
75.Count Words with More Than Three Repeated Letters
76.Key Switch Count
77.Old Algorithm Question: IP
78.Tic Tac Toe Variant Coding Challenge
79.Design a Suspension Game Architecture
80.Design a File Storage System
81.Design a SnapshotSet
82.Fastest Route to Databricks HQ
83.Design a Visa Network System for Authorization Only
84.Describe your most technically challenging project
85.Design a Key-Value Store with Timestamps
1. lazy array
// lazy array,要求实现arraymap(…).indexOf(…),其中map传进去一个function,
//indexOf返回运行了所有function之后传入值的index。要求map的操作最后再做,所以叫 lazy array。 For example:
// arr = LazyArray([10,20, 30,40, 50])
/arrmap(lambdaxx*2)indexOf(40)---->1
//arrmap(lambda xx*2)map(lambdaxx*3)indexOf(240)->3注意这里重新开了一个chain,上一行的map就不计算在内了
After finishing the implementation, asked about how to make class unit test friendly And write unit test for the class.
Then ask how to improved the performance of lazyArray. My answer is using cache to store chain and correponding calculated value.
2. Design WebCrawler

First write single threaded Web Crawler, Then write multi-threaded WebCrawler
/开始提供了三个utilityfunction:
/(1)fetch(urL:url)->HTML:content:
//(2)parse(HTML:content)->List<URL>;
//(3)save(URL:url,HTML:content)。
//save是把数据存在disk上,"fetch是发个network request,
//parse是in-memory解析html page,
/**
*improve the efficiency by multi-thread
* keys
*1-avoid race condition where 2 threads check same url
*and try to process as next url at same time (this causes duplicate visit on same url)
*use concurrentHashMap put to avoid, since the put (insert entry) lock the segment
of map
* and if return null meaning no such key in map previously which means we can process the url
*2- save is a disk 1/0 where we should put it into a separate thread pool to let it finish byitself
*3- fetch html is a networki/0

*/
3. check obstacles

input:
二维整型数组operations,每一个元素有两种可能,对应两种不同的操作:
1) [1,x]:在坐标(无限延伸)的x位置放一个obstacle
2)[2,l,x]:check当前[x-l,x]上有无obstacle,若有则在结果字符串上append1,否则
在结果字符串上append 0
Return:
字符串res,res.charAt(i)对应在operations中出现的第i个check操作的结果
example:
input :operations=[[1,2],[2,2,3],[1,5],[2,8,1]]
output:”01”
explaination:
a)[1,2]:在×=2上放一个obstacle
b)[2,2,3]在内存在[3-2,3]一个obstacle(x=2),所以往res中append0
C)[1,5]:在x=5上放一个obstacle
d)[2,8,1]因为在[7,8]区间范围内不存在obstacle所以我那个res中append1
d128在内不存在bstacle,所以我那个res中append1
4. 设计total revenue系统
写一个算total revenue的系统,给两个参数,一个list of string priceList,另一个list of
string log
priceList例子:["itemname:priceNumber","cup:10”]
log例子:有点复杂具体忘了,但是全是字符串。大意有三种字符串:1.卖什么物品卖几件
2.打折开始什么物品减价多少maxcount(卖几件后恢复原价)3.打折结束
5. 求figure掉下来之后的board状态
给一个二维度矩阵board,该board中的元素可以为三种char,分别为:1."."代表空格2.’F’代表figure3.’#’代表障碍。其中fiqure是连为一体的,并且会往下掉;当figure遇到障碍或bottom时,整体会停下来。求figure掉下来之后的board状态,返回board。

按要求最小的move steps然后让F进行相应的移动。注意每一列如何找最小的move steps(从上往下每一个#和它之前离他最近的F的差再-1,这些diff求最小值)