查看原文
其他

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

2018-02-08 数据应用学院 大数据应用

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

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

Day 191 

DS Interview Questions

How can you check if a data set or time series is Random?

BA Interview Questions

R language: 

Write a loop containing three random numbers. 

The loop repeats itself exactly ten times before it stops. 

LeetCode Questions

Description:

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

Input: 3

Output: [1,3,3,1]

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

Day 190 答案揭晓

DS Interview Questions

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 Questions

R language: 

Write a nested for-loop which prints 30 numbers (1:10, 2:11, 3:12). 

Those are three clusters of ten numbers each.

The first loop determines the number of clusters (3) via its length. 

Each cluster starts one number higher than the previous one.

The outcome is expected as shown below: 


 [1]  1  2  3  4  5  6  7  8  9 10

 [1]  2  3  4  5  6  7  8  9 10 11

 [1]  3  4  5  6  7  8  9 10 11 12 


x=c(1:10)

for(i in 1: 3){

  for(j in 1)

  print(x)

  x=x+1

Leetcode Questions

Description:

  • Given numRows, generate the first numRows of Pascal’s triangle.

Input: 5

Output:

[

    [1],

   [1,1],

  [1,2,1],

 [1,3,3,1],

[1,4,6,4,1]

]


Solution:

  • 模拟题,根据图上的规律来进行循环

  • 注意防止数组越界

Code:

Time Complexity: O(n^2)

Space Complexity: O(1)



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

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

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