查看原文
其他

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

2018-03-29 数据应用学院 大数据应用

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


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


Day 223


DS Interview Questions

What’s the difference between a generative and discriminative model?


BA Interview Questions

What is the meaning of ‘lifetime value’ (LTV)? What LTV can tell you?


LeetCode Questions

    • Description:

      • Given an array of integers sorted in ascending order, find the starting and ending position of a given target value.

      • Your algorithm’s runtime complexity must be in the order of O(log n).

    • Input: [5, 7, 7, 8, 8, 10] and target value 8

    • Output: [3, 4]

    • Assumptions:

      • If the target is not found in the array, return [-1, -1]


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



Day 222 答案揭晓


DS Interview Questions

Why is “Naive” Bayes naive?

Naive Bayes is considered “Naive” because it makes an assumption which is virtually impossible to see in real-life data: the conditional probability is calculated as the pure product of the individual probabilities of components. This implies the absolute independence of features — a condition probably never met in real life.

Reference: https://www.quora.com/Why-is-naive-Bayes-naive?share=1


BA Interview Questions

SQL: Query the list of CITY names ending with vowels (a, e, i, o, u) from STATION. Your result cannot contain duplicates.

The STATION table is described as follows:

Answer:

SELECT DISTINCT

   city

FROM

   station

WHERE

   city

REGEXP

   '[aeiou]$';


LeetCode Questions

  • Description:

    • Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.

    • (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).

    • You are given a target value to search. If found in the array return its index, otherwise return -1.

  • Input: 4 5 6 7 0 1 2, 5

  • Output: 2

  • Assumptions:

    • You may assume no duplicate exists in the array.

  • Solution:

    • 排序非重复rotated数组,满足二分条件

    • 本题难点在于分情况讨论

  • Code

  • Time Complexity: O(lg n)

  • Space Complexity: O(1)




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

↓↓↓

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

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