Sr Data Scientist Interview Questions

3,376 sr data scientist interview questions shared by candidates

Problem Statement: You are given a starting number of 1. Your task is to reach a target number, t, using two available operations: operator_add: Adds a fixed number, x, to the current number. operator_multiply: Multiplies the current number by a fixed number, y. The objective is to reach the target number, t, by using these operations sequentially. Among all possible ways to reach t, pick the sequence that Maximizes the number of times operator 2 is applied Minimizes the number of times operator 1 is applied among all sequences that maximize usage of operator 2 Constraints: 1 ≤ t ≤ 10^20 1 ≤ x ≤ 1000 2 ≤ y ≤ 1000 Input Format: Three integers: t, x, and y. Output Format: If a solution exists: A list of strings where each string represents an operation followed by the number of times it is applied. The solution should be compact in the sense that consecutive occurrences of the same operator collapse to 1 element in the list. This means that if an element in the list correspond to "operator_add", then the next one should correspond to "operator_multiply" and vice versa. For example, if you want to apply the sequence "operation_add, operation_add, operation_multiply, operation_multiply, operation_multiply, operation_add", then the output should be: ["operator_add 2", "operator_multiply 3", "operator_add 1"]. If no solution exists: A list with one element: "no_solution". Examples: Input 1: t = 54, x = 1, y = 3 Output 1: ["operator_add 1", "operator_multiply 3"] Explanation: Starting from 1, add 1 once to get 2, then multiply the result by 3 thrice (2*3^3 = 54) to get 54. The sequence thus results in the target number. Using operator 2 at least 4 times will result in a number bigger than 54 (3^4 > 54). Hence operator 2 can maximally be used three times. For operator 2 being used three times, operator 1 needs to be used at least once because 3^3 is not equal to 54. Therefore it minimizes the usage of operator 1. Input 2: t = 3 x = 4 y = 4 Output 2: ["no_solution"] Explanation: Both operators increase the number and applying any operator once already results in a number that is too big. [execution time limit] 4 seconds (py3) [memory limit] 1 GB [input] integer64 t Target number: the number you want to reach by sequentially applying the operators. [input] integer64 x By how much you increase the current result if you apply operator1. [input] integer64 y By how much you multiply the current result if you apply operator2. [output] array.string List of strings where element i equals "operator_add" or "operator_multiply" followed by how many times you want to apply it. In case there is no solution, output is ["no_solution"].
avatar

Senior Data Scientist

Interviewed at Agoda

3.9
Oct 19, 2023

Problem Statement: You are given a starting number of 1. Your task is to reach a target number, t, using two available operations: operator_add: Adds a fixed number, x, to the current number. operator_multiply: Multiplies the current number by a fixed number, y. The objective is to reach the target number, t, by using these operations sequentially. Among all possible ways to reach t, pick the sequence that Maximizes the number of times operator 2 is applied Minimizes the number of times operator 1 is applied among all sequences that maximize usage of operator 2 Constraints: 1 ≤ t ≤ 10^20 1 ≤ x ≤ 1000 2 ≤ y ≤ 1000 Input Format: Three integers: t, x, and y. Output Format: If a solution exists: A list of strings where each string represents an operation followed by the number of times it is applied. The solution should be compact in the sense that consecutive occurrences of the same operator collapse to 1 element in the list. This means that if an element in the list correspond to "operator_add", then the next one should correspond to "operator_multiply" and vice versa. For example, if you want to apply the sequence "operation_add, operation_add, operation_multiply, operation_multiply, operation_multiply, operation_add", then the output should be: ["operator_add 2", "operator_multiply 3", "operator_add 1"]. If no solution exists: A list with one element: "no_solution". Examples: Input 1: t = 54, x = 1, y = 3 Output 1: ["operator_add 1", "operator_multiply 3"] Explanation: Starting from 1, add 1 once to get 2, then multiply the result by 3 thrice (2*3^3 = 54) to get 54. The sequence thus results in the target number. Using operator 2 at least 4 times will result in a number bigger than 54 (3^4 > 54). Hence operator 2 can maximally be used three times. For operator 2 being used three times, operator 1 needs to be used at least once because 3^3 is not equal to 54. Therefore it minimizes the usage of operator 1. Input 2: t = 3 x = 4 y = 4 Output 2: ["no_solution"] Explanation: Both operators increase the number and applying any operator once already results in a number that is too big. [execution time limit] 4 seconds (py3) [memory limit] 1 GB [input] integer64 t Target number: the number you want to reach by sequentially applying the operators. [input] integer64 x By how much you increase the current result if you apply operator1. [input] integer64 y By how much you multiply the current result if you apply operator2. [output] array.string List of strings where element i equals "operator_add" or "operator_multiply" followed by how many times you want to apply it. In case there is no solution, output is ["no_solution"].

Viewing 2181 - 2190 interview questions

Glassdoor has 3,376 interview questions and reports from Sr data scientist interviews. Prepare for your interview. Get hired. Love your job.