每日一练 | Data Scientist amp; Business Analyst amp; Leetcode 面试题 1582_复杂度_日起_司法部

点击上方 蓝字 会变美

Feb.

17

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

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

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

Day

1482

DS Interview Question

What is the Box-Cox transformation used for?

BA Interview Question

Duplicate Emails

展开全文

Write a SQL query to find all duplicate emails in a table named Person.

| Id | Email |

| 1 | a@b.com |

| 2 | c@d.com |

| 3 | a@b.com |

For example, your query should return the following for the above table:

| Email |

| a@b.com |

Note: All emails are in lowercase.

LeetCode Question

Two Sum

Deion:

Given an array of integers, return indices of the two numbers such that they add up to a specific target.

You may assume that each input would have exactly one solution, and you may not use the same element twice

Input: [2, 7, 11, 15]

Output: [0, 1]

Assumptions: 1. each input would have exactly one solution

2. you may not use the same element twice

3. sorted in ascending order

Day

1481

答案揭晓

DS Interview Question & Answer

What is the difference between stochastic gradient descent (SGD) and gradient descent (GD)?

Both algorithms are methods for finding a set of parameters that minimize a loss function by evaluating parameters against data and then making adjustments.

In standard gradient descent, you'll evaluate all training samples for each set of parameters. This is going to take big, slow steps toward the solution.

In stochastic gradient descent, you'll evaluate only a certain part of training samples for the set of parameters before updating them. This is going to take small, quick steps toward the solution.

BA Interview Question & Answer

Employees Earning More Than Their Managers

The Employee table holds all employees including their managers. Every employee has an Id, and there is also a column for the manager Id.

| Id | Email |

| 1 | a@b.com |

| 2 | c@d.com |

| 3 | a@b.com |

Given the Employee table, write a SQL query that finds out employees who earn more than their managers. For the above table, Joe is the only employee who earns more than his manager.

| Email |

| a@b.com |

Answer:

# Join

select e1.name from Employee e1

join Employee e2 on e1.ManagerId=e2.Id

where e1.Salary>e2.Salary;

OR

# where

select e1.name from Employee e1,Employee e2

where e1.ManagerId=e2.Id

and e1.Salary>e2.Salary;

Reference:

/

LeetCode Question & Answer

Pascal’s Triangle II

Deion:

Given an index k, return the kth row of the Pascal’s triangle.

Input: 3

Output: [1,3,3,1]

Assumptions:

Could you optimize your algorithm to use only O(k) extra space?

Solution:

Pascal’s Triangle 的follow up,重点在于O(k)的空间复杂度

通过滚动数组的方式可以达到O(k)的空间复杂度

Code:

Time Complexity: O(k ^ 2)

Space Complexity: O(k)

ChatGPT助长学术造假,被多国禁止使用,OpenAI推出AI文本分类器

报告:埃隆·马斯克对Twitter支付已有愿景,团队负责构建基础设施

Microsoft与OpenAI拓展合作伙伴关系

司法部起诉Google垄断数字广告技术

研究人员利用AI驱动的数据库在30天内设计出潜在的抗癌药物

点「在看」的人都变好看了哦

特别声明

本文仅代表作者观点,不代表本站立场,本站仅提供信息存储服务。

分享:

扫一扫在手机阅读、分享本文