查看原文
其他

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

数据应用学院 大数据应用 2018-07-13

自2017年6月15日起,数据应用学院与你一起温习数据科学(DS)和商业分析(BA)领域常见的面试问题。从2017年10月4号起,每天再为大家分享一道Leetcode算法题。


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


Day 231


DS Interview Questions

Explain bagging.


BA Interview Questions

Write a SQL query to retrieve the unique job_id and there average salary from the employees table which unique job_id have a salary is smaller than (the maximum of averages of min_salary of each unique job_id from the jobs table which job_id are in the list, picking from (the job_history table which is within the department_id 50 and 100))

Sample table: employees


Sample table: jobs


Sample table: job_history


LeetCode Questions

    Description:

      • You are given an n x n 2D matrix representing an image.

      • Rotate the image by 90 degrees (clockwise).

      • You have to rotate the image in-place, which means you have to modify the input 2D matrix directly.

      • DO NOT allocate another 2D matrix and do the rotation.

    Input:

    [

     [1,2,3],

     [4,5,6],

     [7,8,9]

    ],

    Output:

    [

     [7,4,1],

     [8,5,2],

     [9,6,3]
    ]


欲知答案如何?请见下期分解!



Day 230 答案揭晓


DS Interview Questions

How can you choose a classifier based on training set size?

If training set is small, high bias / low variance models (e.g. Naive Bayes) tend to perform better because they are less likely to be overfit.


If training set is large, low bias / high variance models (e.g. Logistic Regression) tend to perform better because they can reflect more complex relationships.


BA Interview Questions

Explain when you would use WHERE versus HAVING statements.

Answers: Both WHERE and HAVING clause is used in a SELECT query with aggregate function or GROUP BY clause. WHERE clause is used for filtering rows and it applies on each and every row, while HAVING clause is used to filter groups in SQL. You can simply understand the difference as WHERE clause is filtering data before grouping and HAVING clause is filtering after grouping.


LeetCode Questions

  • Description:

    • Given a collection of numbers that might contain duplicates, return all possible unique permutations.

  • Input: [1,1,2]

  • Output: [[1,1,2],[1,2,1],[2,1,1]]

Solution:

  • Permutation 的 follow up,经典的去重题

  • 与combination一样,要选代表,不同的就是combination是通过start记录历史,而permutation是使用set

  • 去重第一个要想到排序

  • 去重的部分使用注释标识了


  • Code:




点击“阅读原文”查看数据应用学院核心课程

↓↓↓ 

    您可能也对以下帖子感兴趣

    文章有问题?点此查看未经处理的缓存