Hello Friends, How are you? Today I am going to solve the HackerRank Maximize It Python Problem with a very easy explanation. In this article, you will get more than one approach to solve this problem. So let’s start- {tocify} $title={Table of Contents}
You are given a function f(X) = X^2. You are also given K lists. The ith list consists of Ni elements. You have to pick one element from each list so that the value from the equation below is maximized: S = (f(X1) + f(X2) + … + f(Xk))%M Xi denotes the element picked from the ith list. Find the maximized value Smax obtained. % denotes the modulo operator. Note that you need to take exactly one element from each list, not necessarily the largest element. You add the squares of the chosen elements and perform the modulo operation. The maximum value that you can obtain, will be the answer to the problem. The first line contains 2 space separated integers K and M. The next K lines each contain an integer Ni, denoting the number of elements in the ith list, followed by Ni space separated integers denoting the elements in the list. 1