All Posts

Leetcode 2859: Sum of Values at Indices With K Set Bits

Given a list of integers and an integer k, return the sum of all elements whose indices have exactly k set bits in their binary representation.

Leetcode 2860: Happy Students

You are given a list of integers where each integer represents a student’s happiness threshold. The task is to determine the number of ways to select a group of students so that all students in the group remain happy.

Leetcode 2861: Maximum Number of Alloys

You are running a company that manufactures alloys using various types of metals. There are n different metal types available, and you have k machines that can be used to create alloys. Each machine requires a specific amount of each metal type to create an alloy. The i-th machine requires composition[i][j] units of metal type j. You have stock[i] units of metal type i, and purchasing one unit of metal type i costs cost[i] coins. Your task is to maximize the number of alloys you can produce while staying within a budget of budget coins. Each alloy must be made using the same machine.

Leetcode 2865: Beautiful Towers I

You are given an array heights representing the number of bricks in n consecutive towers. Your task is to remove some bricks to form a mountain-shaped tower arrangement. In this arrangement, the tower heights are non-decreasing, reaching a maximum peak value with one or multiple consecutive towers and then non-increasing. Return the maximum possible sum of heights of a mountain-shaped tower arrangement.

Leetcode 2866: Beautiful Towers II

You are given an array maxHeights of n integers. Your task is to build n towers in the coordinate line where the height of the i-th tower is between 1 and maxHeights[i]. The configuration is beautiful if the heights form a mountain array, where heights increase to a peak and then decrease afterward. Return the maximum possible sum of the heights of a beautiful tower configuration.

Leetcode 2869: Minimum Operations to Collect Elements

You are given an array nums containing positive integers and an integer k. In each operation, you can remove the last element from the array and add it to your collection. Your task is to determine the minimum number of operations needed to collect all elements from 1 to k (inclusive).