<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-KVGHS6G" height="0" width="0" style="display:none;visibility:hidden"></iframe>

ZipRecruiter计算机科学面试真题

职位分类
全部
数据相关
计算机科学
人工智能
产品经理
BQ
面试题
全部(8)
OOD(0)
Algorithm(7)
System Design(0)
高频题(0)
Math(0)
全部(8)
OOD(0)
Algorithm(7)
System Design(0)
高频题(0)
Math(0)
1.Collision Detection Algorithm
2.Race Car Elimination Algorithm
3.Priority Queue Implementation
4.Optimal Lamp Placement
5.Command Type Counting
6.Array Sum and Update Operations
7.Count Pairwise Distinct Digits
8.Find the Most Frequent Word in a Dictionary
1. Collision Detection Algorithm
Given an array of pairs of integers representing coordinates of objects and a square area around its center with a side equal to 2, write a function to calculate the number of object pairs that collide. Two objects are supposed to collide if their collision boxes have at least one common point. Explain how you would implement this function and discuss its time and space complexity.
2. Race Car Elimination Algorithm
Given a two-dimensional string array representing drivers' names and their lap times in seconds, write an algorithm to return the drivers in the order they are eliminated, ending with the last driver or drivers remaining. If multiple drivers are eliminated on the same lap, their names should be listed alphabetically. Provide a solution with time complexity not worse than O(laps.length * laps[0].length), and explain why your solution meets this requirement.
3. Priority Queue Implementation
Describe how you would implement a priority queue. What data structures would you use and why? Discuss the time complexity of the operations involved.
4. Optimal Lamp Placement
There are some objects placed on a number line, and you are given their coordinates in ascending order in an object array. There are no two objects placed at the same position. You need to place a lamp on an integer coordinate on the same line so that it illuminates the maximum number of objects. Return the coordinate of the lamp. For example, if the objects are [-5,3,4,9] and the radius of the lamp is 5, then the output should be -1, because the lamp placed at position -1 can illuminate 3 objects.
5. Command Type Counting
Given a string array with commands in it, their types are 'ls', 'cp', 'mv', and '!'. The '!' command is used to repeat the 'index-th' command (1-based) since the start of the session. You need to return how many times the commands 'ls', 'cp', and 'mv' are called. For example, given the input array (ls, cp, mv, mv, !1, !5), '!1' calls 'ls', and '!5' calls '!1' which in turn calls 'ls', so the return should be 'ls' is called 2 times.