Showing 32 questions
Reverse a linked list in groups of k nodes. If the number of nodes is not a multiple of k, leave the remaining nodes at the end as is.
#1. Reverse Nodes in k-Group
You're given resources and machine blueprints. Determine the maximum number of identical alloys you can create by optimally distributing your resources across the machines.
#2. Maximum Number of Alloys
You are given an array and two numbers, minK and maxK. Find the number of subarrays where minK and maxK are the minimum and maximum values within that subarray, respectively.
#3. Count Subarrays With Fixed Bounds
You are given a matrix and asked to reshape it into a new matrix with a different number of rows and columns. Determine if reshaping is possible and, if so, return the reshaped matrix.
#4. Reshape the Matrix
You are given an inventory of colored balls, each with a value equal to its count. Determine the maximum total value you can obtain by selling a limited number of these balls, given that each sale reduces the ball's value by one.
#5. Sell Diminishing-Valued Colored Balls
You're given a string and can rearrange its characters. Determine the maximum number of palindromes you can create using all the characters after each of several rearrangement operations.
#6. Maximum Palindromes After Operations
You're given a list of worker costs and need to hire exactly K workers. Determine the minimum total cost to hire these workers by strategically selecting them from the cheapest available at either end of the list.
#7. Total Cost to Hire K Workers
Two players alternate removing colored pieces from a line. Determine who wins if both neighbors of a piece are the same color, and players try to maximize their moves.
#8. Remove Colored Pieces if Both Neighbors are the Same Color
You're given an array and a corresponding array of processing times. Determine the earliest second you can mark all indices in the first array, given constraints on processing order and time.
#9. Earliest Second to Mark Indices II
Find the lexicographically largest substring within a given string. Return this last substring.
#10. Last Substring in Lexicographical Order
You're given an array where each number represents the time needed to mark a specific index. Find the earliest second at which you can mark all indices in another given array.
#11. Earliest Second to Mark Indices I
#12. Count Anagrams
You are given a binary tree. Place cameras on some nodes such that all nodes are either covered by a camera on itself, or on one of its parents or children. Minimize the number of cameras used.
#13. Binary Tree Cameras
Imagine you're buying items and have special offers that combine multiple items for a cheaper price. Your goal is to find the minimum cost to purchase a specific list of items, using a combination of individual prices and special offers.
#14. Shopping Offers
You are given an array of leaf node values. Construct a binary tree and minimize the total cost, where the cost is the sum of the products of each non-leaf node's children.
#15. Minimum Cost Tree From Leaf Values
Determine which words from a given list can be typed using only one row of the standard QWERTY keyboard. Return these valid words.
#16. Keyboard Row
Imagine passing a pillow around a circle of people. Given the number of people and the number of passes, determine which person ends up with the pillow.
#17. Pass the Pillow
Determine if one string can be transformed into another by repeatedly moving a character to the beginning of the string. Return the minimum number of moves required, or -1 if it's impossible.
#18. String Transformation
You're given a directed graph. Determine the minimum number of edges you need to reverse so that every node becomes reachable from node 0.
#19. Minimum Edge Reversals So Every Node Is Reachable
Given an array of integers, determine how many triplets sum up to a multiple of a given number. Count the number of such divisible triplets.
#20. Number of Divisible Triplet Sums