Data Application Lab 自2017年6月15日起,每天和你分享討論一道數據科學(DS)和商業分析(BA)領域常見的面試問題。
自2017年10月4日起,每天再為大家分享一道Leetcode 算法題。
希望積極尋求相關領域工作的你每天關注我們的問題並且與我們一起思考,我們將會在第二天給出答案。
How can you check if a data set or time series is Random?
Write a query in SQL to obtain the name of the physicians with department who are yet to be affiliated.
Sample table: physician
employeeid | name | position | ssn
--+----++---
1 | John Dorian | Staff Internist | 111111111
2 | Elliot Reid | Attending Physician | 222222222
3 | Christopher Turk | Surgical Attending Physician | 333333333
4 | Percival Cox | Senior Attending Physician | 444444444
5 | Bob Kelso | Head Chief of Medicine | 555555555
6 | Todd Quinlan | Surgical Attending Physician | 666666666
7 | John Wen | Surgical Attending Physician | 777777777
8 | Keith Dudemeister | MD Resident | 888888888
9 | Molly Clock | Attending Psychiatrist | 999999999
Sample table: procedure
code | name | cost
-+----+
1 | Reverse Rhinopodoplasty | 1500
2 | Obtuse Pyloric Recombobulation | 3750
3 | Folded Demiophtalmectomy | 4500
4 | Complete Walletectomy | 10000
5 | Obfuscated Dermogastrotomy | 4899
6 | Reversible Pancreomyoplasty | 5600
7 | Follicular Demiectomy | 25
Next Permutation
Description:
Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.
If such arrangement is not possible, it must rearrange it as the lowest possible order (ie, sorted in ascending order).
The replacement must be in-place, do not allocate extra memory.
Input: 1,2,3
Output: 1,3,2
DS Interview Question & Answer
Can the lambda forms in Python contain statements?
No, as their syntax is restricted to single expressions and they are used for creating function objects which are returned at runtime.
This list of questions for Python interview questions and answers is not an exhaustive one and will continue to be a work in progress. Let us know in comments below if we missed out on any important question that needs to be up here.
BA Interview Question & Answer
Write a query in SQL to obtain the name of the physicians who are trained for a special treatment.
Sample table: physician
Employeeid | name | position | ssn
--++---+-
1 | John Dorian | Staff Internist | 111111111
2 | Elliot Reid | Attending Physician | 222222222
3 | Christopher Turk | Surgical Attending Physician | 333333333
4 | Percival Cox | Senior Attending Physician | 444444444
5 | Bob Kelso | Head Chief of Medicine | 555555555
6 | Todd Quinlan | Surgical Attenian | 666666666
7 | John Wen | Surgical Attending Physician | 777777777
8 | Keith Dudemeister | MD Resident | 888888888
9 | Molly Clock | Attending Psychiatrist | 999999999
Sample table: procedure
code | name | cost
-+---+---
1 | Reverse Rhinopodoplasty | 1500
2 | Obtuse Pyloric Recombobulation | 3750
3 | Folded Demiophtalmectomy | 4500
4 | Complete Walletectomy | 10000
5 | Obfuscated Dermogastrotomy | 4899
6 | Reversible Pancreomyoplasty | 5600
7 | Follicular Demiectomy | 25
Answer:
SELECT p.name AS "Physician",
c.name AS "Treatment"
FROM physician p,
procedure c,
trained_in t
WHERE t.physician=p.employeeid
AND t.treatment=c.code;
Sample Output:
Physician | Treatement
---+--
Christopher Turk | Reverse Rhinopodoplasty
Christopher Turk | Obtuse Pyloric Recombobulation
Christopher Turk | Obfuscated Dermogastrotomy
Christopher Turk | Reversible Pancreomyoplasty
Christopher Turk | Follicular Demiectomy
Todd Quinlan | Obtuse Pyloric Recombobulation
Todd Quinlan | Obfuscated Dermogastrotomy
Todd Quinlan | Reversible Pancreomyoplasty
John Wen | Reverse Rhinopodoplasty
John Wen | Obtuse Pyloric Recombobulation
John Wen | Folded Demiophtalmectomy
John Wen | Complete Walletectomy
John Wen | Obfuscated Dermogastrotomy
John Wen | Reversible Pancreomyoplasty
John Wen | Follicular Demiectomy
(15 rows)
LeetCode Question & Answer
Description:
Given two integers n and k, return all possible combinations of k numbers out of 1 … n.
Input: n = 4 and k = 2
Output: [[2,4],[3,4],[2,3],[1,2],[1,3],[1,4],]
Solution:
注意邊界條件判斷
combination的變形
因為長度限定,所以可以剪枝優化,優化的地方用pluning注釋了
Code:
往期精彩回顧
點擊「閱讀原文」查看數據應用學院核心課程