Company: Databrick

Difficulty: medium

Problem Statement

Problem Description Imagine you are tracking how a user's rating changes over time on an online platform. Every user has an overall rating (an integer between 1 and 2500) and a level derived from that rating according to these rules: rating < 1000 = "beginner"; 1000 ≤ rating < 1500 = "intermediate"; 1500 ≤ rating < 2000 = "advanced"; 2000 ≤ rating = "pro". You are given a starting rating value and an array of integers changes describing how the rating moves over time. Your task is to compute the final rating and return the level that corresponds to it. It is guaranteed that the rating will never drop below 1 or rise above 2500 as the changes are applied. Note: You are not expected to provide the most optimal solution, but a solution with time complexity not worse than O(changes.length^2) will fit within the execution time limit. Examples Example 1 Input: initial = 1500, changes = [-100, -300, 450, 500, -500, -600] Output: "beginner" Explanation The rating moves as follows: 150

More Databrick OA questionsInterview experiences