注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号
x
我也发个上周zenefits的面经吧 已经挂了
三轮skype技术面, 一轮和manager聊天, 说是相当于onsite
第一轮两个题目:
(1)You are given an array a of sizeN. The elements of the array area[0], a[1], ... a[N - 1], where each a is either 0 or 1. You can perform one transformation on the array: choose any two integers [i]L,and R, and flip all the elements between (and including) the Lth and Rth bits. In other words, L and R represent the left-most and the right-most index demarcating the boundaries of the segment whose bits you will decided to flip. ('Flipping' a bit means, that a 0 is transformed to a 1 and a 1 is transformed to a 0.)
What is the maximum number of '1'-bits (indicated by S) which you can obtain in the final bit-string?
Input Format:
The first line has a single integerN
The next N lines contains the Nelements in the array,a[0], a[1], ... a[N - 1], one per line.
Note: Feel free to re-use the input-output code stubs provided.
Output format:
Return a single integer that denotes the maximum number of 1-bits which can be obtained in the final bit string
Constraints:
1 ≤ N ≤ 100,000
d can be either [i]0 or 1. It cannot be any other integer.
0 ≤ L ≤ R < N
Sample Input: 810010010
Sample Output: 6
Explanation:
We can get a maximum of 6 ones in the given binary array by performing either of the following operations:
Flip [1, 5] ⇒ 1 1 1 0 1 1 1 0
or
Flip [1, 7] ⇒ 1 1 1 0 1 1 0 1
(2)Given N unique positive integers, we want to count the total pairs of numbers whose difference is K. The solution should minimize computational time complexity to the best of your ability
Input Format:
1st line contains N and K, which are integers separated ne city (Bay Area) - 50K people, and one sparsely populated country (US) - 500K people.
[size=12.8000001907349px]Each person has on average 5K interest_ids, which is a random number between 1 and 10K (interest_ids are not necessarily numbered 1 to 10K). Number of people who have a specific interest_id tends to follow power law distribution, with 20% of interests having 80% of user_ids, recursively.
[size=12.8000001907349px]Scoring: It’s a function of: [size=12.8000001907349px]- Time taken for the program to run. [size=12.8000001907349px]- Number of words of code. Therefore obfuscation doesn’t help much, you can gladly give large variable names. The idea is to keep the logic extremely simple. [size=12.8000001907349px]
[size=12.8000001907349px]
[size=12.8000001907349px]
|