2862. Maximum Element-Sum of a Complete Subset of Indices
You are given a 1**-indexed** array
numsofnintegers.A set of numbers is complete if the product of every pair of its elements is a perfect square.
For a subset of the indices set
{1, 2, ..., n}represented as{i1, i2, ..., ik}, we define its element-sum as:nums[i1] + nums[i2] + ... + nums[ik].Return the maximum element-sum of a complete subset of the indices set
{1, 2, ..., n}.A perfect square is a number that can be expressed as the product of an integer by itself.
2861. Maximum Number of Alloys
You are the owner of a company that creates alloys using various types of metals. There are
ndifferent types of metals available, and you have access tokmachines that can be used to create alloys. Each machine requires a specific amount of each metal type to create an alloy.For the
ithmachine to create an alloy, it needscomposition[i][j]units of metal of typej. Initially, you havestock[i]units of metal typei, and purchasing one unit of metal typeicostscost[i]coins.Given integers
n,k,budget, a 1-indexed 2D arraycomposition, and 1-indexed arraysstockandcost, your goal is to maximize the number of alloys the company can create while staying within the budget ofbudgetcoins.All alloys must be created with the same machine.
Return the maximum number of alloys that the company can create.
You are given a 0-indexed integer array
numsof lengthnwherenis the total number of students in the class. The class teacher tries to select a group of students so that all the students remain happy.The
ithstudent will become happy if one of these two conditions is met:
- The student is selected and the total number of selected students is strictly greater than
nums[i].- The student is not selected and the total number of selected students is strictly less than
nums[i].Return the number of ways to select a group of students so that everyone remains happy.
2859. Sum of Values at Indices With K Set Bits
You are given a 0-indexed integer array
numsand an integerk.Return an integer that denotes the sum of elements in
numswhose corresponding indices have exactlykset bits in their binary representation.The set bits in an integer are the
1‘s present when it is written in binary.
- For example, the binary representation of
21is10101, which has3set bits.