最近收到了 Adobe 招聘的消息,是关于 MTS-2(Member of Technical Staff - 2) 的岗位。一位 Adobe 的 HR 主动联系了我,说这是一次 集中式的 hiring drive,所以所有的面试轮次会在 同一天内完成,节奏会比较紧凑。
Round 1:算法与数据结构(Problem Solving - DSA)
Given an array of words and an array of sentences, calculate how many sentences can be created by replacing any word with one of its anagrams.
Note:
• Two words are said to be anagrams of each other if one can be created by rearranging the letters of another word, using all the original letters exactly once.
wordSet = ['listen', 'silent', 'it', 'is']
sentences = 'listen it is silent', 'silent it is silent'
wordSet = ['cat', 'act', 'is']
sentences = 'cat is tac', 'act tac is cat'
Write the countSentences function in the editor below.
countSentences has the following parameters:
• string wordSet[n]: an array of strings
• string sentences[m]: an array of strings
Returns:
• int[]: an array of m integers that denote the number of sentences that can be formed from each sentence
Question 2:
Imagine you are designing the organizational hierarchy of a large company. In this structure, each node represents a department, and the edges represent direct managerial relationships between departments.
• The company consists of n departments, labeled from 0 to n - 1.
• You are given n - 1 manager-subordinate relationships in the form of an array edges, where each element [a_i, b_i] indicates that department a_i is the direct manager of department b_i, or vice versa. This structure forms a tree (i.e., there are no circular managerial chains).
Task:
Your goal is to choose the most efficient department to serve as the central management hub for the entire company. The height of the hierarchy represents the longest managerial chain (in terms of reporting lines) from the central management department to the most distant department.
In a well-designed organizational structure, you want the central management department to be as close as possible to all other departments, minimizing the distance (in terms of reporting lines) to any department.
Objective:
You need to identify which departments can serve as the best central management hubs. These are the departments that, when selected as the central hub, result in the shortest longest reporting chain to the most distant department. This ensures that communication and decision-making processes are as efficient as possible.
Output:
Return a list of all the departments (node labels) that can act as the best central management hubs for the company. The answer can be returned in any order.
Input: n = 4, edges = [[1,0],[1,2],[1,3]]
Output: [1]
Input: n = 6, edges = [[3,0],[3,1],[3,2],[3,4],[5,4]]
Output: [3,4]
Round 2: Problem Solving(DSA)
Question 1:
Imagine you are designing the organizational hierarchy of a large company. In this structure, each node represents a department, and the edges represent direct managerial relationships between departments.
• The company consists of n departments, labeled from 0 to n - 1.
• You are given n - 1 manager-subordinate relationships in the form of an array edges, where each element [a_i, b_i] indicates that department a_i is the direct manager of department b_i, or vice versa. This structure forms a tree (i.e., there are no circular managerial chains).
Task:
Your goal is to choose the most efficient department to serve as the central management hub for the entire company. The height of the hierarchy represents the longest managerial chain (in terms of reporting lines) from the central management department to the most distant department.
In a well-designed organizational structure, you want the central management department to be as close as possible to all other departments, minimizing the distance (in terms of reporting lines) to any department.
Objective:
You need to identify which departments can serve as the best central management hubs. These are the departments that, when selected as the central hub, result in the shortest longest reporting chain to the most distant department. This ensures that communication and decision-making processes are as efficient as possible.
Output:
Return a list of all the departments (node labels) that can act as the best central management hubs for the company. The answer can be returned in any order.
Input: n = 4, edges = [[1,0],[1,2],[1,3]]
Output: [1]
Input: n = 6, edges = [[3,0],[3,1],[3,2],[3,4],[5,4]]
Output: [3,4]
O(Number of nodes)
Question 2:
Imagine you're working with an e-commerce platform that tracks customer interactions with products. The platform collects data about which products users view, add to their cart, and purchase. As part of the product recommendation system, you need to identify the most popular products, i.e., the products that are viewed the most often.
Problem Statement:
Given an array nums representing the product IDs that customers have viewed, and an integer k, you need to identify the k most frequent product IDs. These products are the ones that are viewed most often, and they will be recommended to users.
Example:
• Product Views (nums): [1, 2, 3, 1, 1, 4, 2, 2, 5, 6, 2]
• k: 3
Output: [2, 1, 3]