每日一练 | Data Scientist & Business Analyst & Leetcode 面试题 299
自2017年6月15日起,数据应用学院与你一起温习数据科学(DS)和商业分析(BA)领域常见的面试问题。从2017年10月4号起,每天再为大家分享一道Leetcode算法题。
希望积极寻求相关领域工作的你每天关注我们的问题并且与我们一起思考,我们将会在第二天给出答案。
DS Interview Questions
What are hash table collisions? How is it avoided?
BA Interview Questions
Using the following variables:
x=1
i=c(1:10)
## write a for() loop that increments x by two for each i.
Leetcode Questions
Description:
A peak element is an element that is greater than its neighbors.
Given an input array where num[i] ≠ num[i+1], find a peak element and return its index.
The array may contain multiple peaks, in that case return the index to any one of the peaks is fine.
Input: [1, 2, 3, 1]
Output: 2
Assumptions:
You may imagine that num[-1] = num[n] = -∞
欲知答案如何?请见下期分解!
Day 198 答案揭晓
DS Interview Questions
How would you create a taxonomy to identify key customer trends in unstructured data?
The best way to approach this question is to mention that it is good to check with the business owner and understand their objectives before categorizing the data. Having done this, it is always good to follow an iterative approach by pulling new data samples and improving the model accordingly by validating it for accuracy by soliciting feedback from the stakeholders of the business. This helps ensure that your model is producing actionable results and improving over the time.
BA Interview Questions
R language:
Use the ‘rivers’ dataset to write a for loop. The loop prints the dataset:
rivers shorter than 500 are a ‘short river’;
rivers longer than 2000 are a ‘long river’;
and rivers in the middle range are printed in their original numbers.
data(rivers)
rivers<-data.frame(rivers)
rivers$length<-NA
str(rivers)
for(i in 1:nrow(rivers)){
if(rivers$rivers[i]<500){rivers$length[i]<-'short river'}
else if(rivers$rivers[i]>2000){rivers$length[i]<-'long river'}
else{rivers$length[i]<-rivers$rivers[i]}
}
str(rivers)
Leetcode Questions
Description:
Write a program to find the node at which the intersection of two singly linked lists begins.
Input:
A: a1 → a2
↘
c1 → c2 → c3
↗
B: b1 → b2 → b3
Output: c1
Assumptions:
The array may contain duplicates.
Solution:
这道题的基础解法是使用hashtable遍历其中一条链表,存储经过的节点,在与另一个链表一一比较
最优的解法请参考如下solution,从算法的角度来讲记下来就好,如果有兴趣做数学证明的也可以尝试一下
点击“阅读原文”查看数据应用学院核心课程