专栏名称: 大数据应用
数据应用学院被评为2016北美Top Data Camp, 是最专业一站式数据科学咨询服务机构,你的数据科学求职咨询专家!
目录
相关文章推荐
CDA数据分析师  ·  【2月】CDA网校2025 ... ·  3 天前  
软件定义世界(SDX)  ·  麻省理工科技评论:2025年AI五大趋势 ·  3 天前  
艺恩数据  ·  春节档观众满意度亮眼 ... ·  1 周前  
数据派THU  ·  机器学习过程:特征、模型、优化和评估 ·  3 天前  
51好读  ›  专栏  ›  大数据应用

每日一练 | Data Scientist & Business Analyst & Leetcode 面试题 723

大数据应用  · 公众号  · 大数据  · 2019-10-19 08:32

正文


点击上方 蓝字 会变美




Oct.

18

Data Application Lab 自2017年6月15日起,每天和你分享讨论一道数据科学(DS)和商业分析(BA) 领域常见的面试问题。

自2017年10月4日起,每天再为大家分享一道Leetcode 算法题。


希望积极寻求相关领域工作的你每天关注我们的问题并且与我们一起思考,我们将会在第二天给出答案。

Day

623

DS Interview Question

What are the primary differences & similarity between classification and regression trees.

BA Interview Question

Rank Scores


Write a SQL query to rank scores. If there is a tie between two scores, both should have the same ranking. Note that after a tie, the next ranking number should be the next consecutive integer value. In other words, there should be no "holes" between ranks.
+----+-------+
| Id | Score |
+----+-------+
| 1  | 3.50  |
| 2  | 3.65  |
| 3  | 4.00  |
| 4  | 3.85  |
| 5  | 4.00  |
| 6  | 3.65  |
+----+-------+

For example, given the above Scores table, your query should generate the following report (order by highest score):
+-------+------+
| Score | Rank |
+-------+------+
| 4.00  | 1    |
| 4.00  | 1    |
| 3.85  | 2    |
| 3.65  | 3    |
| 3.65  | 3    |
| 3.50  | 4    |
+-------+------+

LeetCode Question

Max Subarray


Description:

Find the contiguous subarray within an array (containing at least one number) which has the largest sum.

Input: [-2,1,-3,4,-1,2,1,-5,4]

Output: 6

Assumptions:

containing at least one number

Day

622

答案揭晓

DS Interview Question & Answer

What’s the advantages and disadvantages of decision tree.

Advantage:


Easy to Understand: Decision tree output is very easy to understand. Its graphical representation is very intuitive and users can easily relate their hypothesis.

Useful in Data exploration: Decision tree is one of the fastest way to identify most significant variables and relation between two or more variables. With the help of decision trees, we can create new variables / features that has better power to predict target variable. It can also be used in data exploration stage. For example, we are working on a problem where we have information available in hundreds of variables, there decision tree will help to identify most significant variable.


Less data cleaning required: It requires less data cleaning compared to some other modeling techniques. It is not influenced by outliers and missing values to a fair degree.


Data type is not a constraint: It can handle both numerical and categorical variables.

Non Parametric Method: Decision tree is considered to be a non-parametric method. This means that decision trees have no assumptions about the space distribution and the classifier structure.


Disadvantages:


Overfitting: Overfitting is one of the most practical difficulty for decision tree models. This problem gets solved by setting constraints on model parameters and pruning.


Not fit for continuous variables: While working with continuous numerical variables, decision tree looses information when it categorizes variables in different categories.

BA Interview Question & Answer

Nth Highest Salary


Write a SQL query to get the nth highest salary from the Employee table.

+----+--------+
| Id | Salary |
+----+--------+
| 1  | 100    |
| 2  | 200    |
| 3  | 300    |
+----+--------+

For example, given the above Employee table, the nth highest salary where n = 2 is 200. If there is no nth highest salary, then the query should return null.

+------------------------+
| getNthHighestSalary(2) |
+------------------------+
| 200                    |
+------------------------+


Answer:

CREATE FUNCTION getNthHighestSalary(N INT) RETURNS INT

BEGIN

RETURN (

SELECT IFNULL((SELECT e1.Salary

FROM Employee e1

JOIN Employee e2

ON e2.Salary >= e1.Salary

GROUP BY e1.Salary

HAVING COUNT(DISTINCT e2.Salary) = N

)

,NULL)

);

END

Reference: https://leetcode.com/problems/nth-highest-salary/description/







请到「今天看啥」查看全文