Each day a quarry-worker is given a pile of stones and told to reduce the larger stones into smaller ones. The worker must smash the stones together to reduce them, and is told to always pick up the largest two stones and smash them together. If the stones are of equal weight, they both disintegrate entirely. If one is larger, the smaller one is disintegrated and the larger one is reduced by the weight of the smaller one. Eventually, there is either one stone left that cannot be broken, or all of the stones have been smashed. Determine the weight of the last stone, or return O if there is none. Example weights = [1,2,3,6,7,7]. The worker always starts with the two largest stones. In this case, the two largest stones have equal weights of 7 so they both disintegrate when smashed. Next the worker smashes weights 3 and 6. The smaller one is destroyed and the larger weighs 6 - 3 = 3 units. Then, weights 3 and 2 are smashed together, which leaves a stone of weight 1. This is smashed with the last remaining stone of weight 1. There are no stones left, so the remaining stone weight is 0. Function Description Complete the function lastStoneWeight in the editor below. The function must return an integer that denotes the weight of the last stone, or 0 if all stones shattered into dust. lastStoneWeight has the following parameter(s): int weights[n]: an array of integers indicating the weights of each stone Constraints • 1 5n≤ 105 • 1 ≤ weights[i] ≤ 109
Machine Learning Scientist Interview Questions
467 machine learning scientist interview questions shared by candidates
I was given a data set of different delivery information with actual delivery time reported. I need to choose whatever algo i want to train a model to predict delivery time
I was asked a design question for a recommender system for one of their products.
take home assignment to build model.
Describe a project from your past experience (first question in the interview)
Given a bag of n blue and m red marbles, what's the expected number of draws until you get a blue marble?
Programming on whiteboard: Efficiently compute the inner product of two sparse vectors.
Explain your research in your Ph.D.
Describe a project where there were multiple alternatives from which to choose in implementing it.
Stochastic Gradient Descent: if it is faster, why don't we always use it?
Viewing 41 - 50 interview questions