Data Application Lab 自2017年6月15日起,每天和你分享討論一道數據科學(DS)和商業分析(BA)領域常見的面試問題。
自2017年10月4日起,每天再為大家分享一道Leetcode 算法題。
希望積極尋求相關領域工作的你每天關注我們的問題並且與我們一起思考,我們將會在第二天給出答案。
How can you choose a classifier based on training set size?
Department Highest Salary
The Employee table holds all employees. Every employee has an Id, a salary, and there is also a column for the department Id.
+----+--+---+----+
| Id | Name | Salary | DepartmentId |
+----+--+---+----+
| 1 | Joe | 70000 | 1 |
| 2 | Henry | 80000 | 2 |
| 3 | Sam | 60000 | 2 |
| 4 | Max | 90000 | 1 |
+----+--+---+----+
The Department table holds all departments of the company.
+----++
| Id | Name |
+----++
| 1 | IT |
| 2 | Sales |
+----++
Write a SQL query to find employees who have the highest salary in each of the departments. For the above tables, Max has the highest salary in the IT department and Henry has the highest salary in the Sales department.
+--++---+
| Department | Employee | Salary |
+--++---+
| IT | Max | 90000 |
| Sales | Henry | 80000 |
+--++---+
Find Peak Element
Description:
A peak element is an element that is greater than its neighbors.
Given an input array where num[i] ≠ num[i+1], find a peak element and return its index.
The array may contain multiple peaks, in that case return the index to any one of the peaks is fine.
Input: [1, 2, 3, 1]
Output: 2
Assumptions:
You may imagine that num[-1] = num[n] = -∞.
DS Interview Question & Answer
What are the advantages and disadvantages of neural networks?
Advantages: Neural networks (specifically deep NNs) have led to performance breakthroughs for unstructured datasets such as images, audio, and video. Their incredible flexibility allows them to learn patterns that no other ML algorithm can learn.
Disadvantages: However, they require a large amount of training data to converge. It's also difficult to pick the right architecture, and the internal "hidden" layers are incomprehensible.
BA Interview Question & Answer
Customers Who Never Order
Suppose that a website contains two tables, the Customers table and the Orders table. Write a SQL query to find all customers who never order anything.
Table: Customers.
+----+--+
| Id | Name |
+----+--+
| 1 | Joe |
| 2 | Henry |
| 3 | Sam |
| 4 | Max |
+----+--+
Table: Orders.
+----+--+
| Id | CustomerId |
+----+--+
| 1 | 3 |
| 2 | 1 |
+----+--+
Using the above tables as example, return the following:
+-+
| Customers |
+-+
| Henry |
| Max |
+-+
Answer:
select customers.name as 'Customers'
from customers
where customers.id not in
(select customerid from orders
);
Reference:
https://leetcode.com/problems/customers-who-never-order/description/
LeetCode Question & Answer
Intersection of Two Linked Lists
Description:
Write a program to find the node at which the intersection of two singly linked lists begins.
Input:
A: a1 → a2
↘
c1 → c2 → c3
↗
B: b1 → b2 → b3
Output: c1
Assumptions:
The array may contain duplicates.
Solution:
這道題的基礎解法是使用hashtable遍歷其中一條鍊表,存儲經過的節點,在與另一個鍊表一一比較
最優的解法請參考如下solution,從算法的角度來講記下來就好,如果有興趣做數學證明的也可以嘗試一下
Code:
Time Complexity: O(n)
Space Complexity: O(1)
往期精彩回顧
點擊「閱讀原文」查看數據應用學院核心課程