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

Day

1898

DS Interview Question

What’s the differences between the poission distribution and normal distribution?

LeetCode Question

Write a query in SQL to count the number available rooms.

Sample table: room

roomnumber | roomtype | blockfloor | blockcode | unavailable

-----------+------------+------------+-----------+-------------

101 | Single | 1 | 1 | f

102 | Single | 1 | 1 | f

103 | Single | 1 | 1 | f

111 | Single | 1 | 2 | f

112 | Single | 1 | 2 | t

113 | Single | 1 | 2 | f

121 | Single | 1 | 3 | f

122 | Single | 1 | 3 | f

123 | Single | 1 | 3 | f

201 | Single | 2 | 1 | t

202 | Single | 2 | 1 | f

203 | Single | 2 | 1 | f

211 | Single | 2 | 2 | f

212 | Single | 2 | 2 | f

213 | Single | 2 | 2 | t

221 | Single | 2 | 3 | f

222 | Single | 2 | 3 | f

223 | Single | 2 | 3 | f

301 | Single | 3 | 1 | f

302 | Single | 3 | 1 | t

303 | Single | 3 | 1 | f

311 | Single | 3 | 2 | f

312 | Single | 3 | 2 | f

313 | Single | 3 | 2 | f

321 | Single | 3 | 3 | t

322 | Single | 3 | 3 | f

323 | Single | 3 | 3 | f

401 | Single | 4 | 1 | f

402 | Single | 4 | 1 | t

403 | Single | 4 | 1 | f

411 | Single | 4 | 2 | f

412 | Single | 4 | 2 | f

413 | Single | 4 | 2 | f

421 | Single | 4 | 3 | t

422 | Single | 4 | 3 | f

423 | Single | 4 | 3 | f

BA Interview Question

Rotate Array

Deion:

Rotate an array of n elements to the right by k steps.

For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,4]. Could you do it in-place with O(1) extra space?

Input: [1,2,3,4,5,6,7] 3

Output: [5,6,7,1,2,3,4]

Day

1897

答案揭晓

DS Interview Question & Answer

Define: quality assurance, six sigma.

Quality assurance:

- A way of preventing mistakes or defects in manufacturing products or when delivering services to customers

- In a machine learning context: anomaly detection

Six sigma:

- Set of techniques and tools for process improvement

- 99.99966% of products are defect-free products (3.4 per 1 million)

- 6 standard deviation from the process mean

LeetCode Question & Answer

Write a query in SQL to find the floor and block where the room number 212 belongs to.

Sample table: room

roomnumber | roomtype | blockfloor | blockcode | unavailable

---------------------+---------------+-----------------+----------------+-------------

101 | Single |1 | 1 | f

102 | Single |1 | 1 | f

103 | Single |1 | 1 | f

111 | Single |1 |2 | f

112 | Single |1 |2 | t

113 | Single |1 |2 | f

121 | Single |1 |3 | f

122 | Single |1 |3 | f

123 | Single |1 |3 | f

201 | Single |2 |1 | t

202 | Single |2 |1 | f

203 | Single |2 |1 | f

211 | Single |2 |2 | f

212 | Single |2 |2 | f

213 | Single |2 |2 | t

221 | Single | 2 | 3 | f

222 | Single | 2 | 3 | f

223 | Single | 2 | 3 | f

301 | Single | 3 | 1 | f

302 | Single | 3 | 1 | t

303 | Single |3 |1 | f

311 | Single | 3 |2 | f

312 | Single | 3 |2 | f

313 | Single |3 |2 | f

321 | Single |3 |3 | t

322 | Single |3 |3 | f

323 | Single |3 | 3 | f

401 | Single |4 |1 | f

402 | Single |4 |1 | t

403 | Single |4 |1 | f

411 | Single | 4 |2 | f

412 | Single |4 |2 | f

413 | Single |4 |2 | f

421 | Single |4 |3 | t

422 | Single |4 |3 | f

423 | Single |4 |3 | f

Answer:

SELECT blockfloor AS "Floor",

blockcode AS "Block"

FROM room

WHERE roomnumber=212;

Output:

Floor | Block

-------+-------

2 | 2

(1 row)

BA Interview Question & Answer

Combine Two Tables

Deion:

Write a SQL query for a report that provides the following information for each person in the Person table, regardless if there is an address for each of those people:

FirstName, LastName, City, State

Input:

Table: Person

+-------------+---------+

| Column Name | Type |

+-------------+---------+

| PersonId | int |

| FirstName | varchar |

| LastName | varchar |

+-------------+---------+

PersonId is the primary key column for this table.

Table: Address

+-------------+---------+

| Column Name | Type |

+-------------+---------+

| AddressId | int |

| PersonId | int |

| City | varchar |

| State | varchar |

+-------------+---------+

AddressId is the primary key column for this table.

Solution:因为每个人不管地址存不存在都要在新表中,所以用person表左外连接address表

Code:

SELECT a.FirstName, a.LastName, b.City, b.State

FROM Person a

LEFT OUTER JOIN Address b

on a.PersonId = b.PersonId;返回搜狐,查看更多

平台声明:该文观点仅代表作者本人,搜狐号系信息发布平台,搜狐仅提供信息存储空间服务。
阅读 ()