Showing 126 questions
Given a string 't', and a target string 's', find the maximum number of times 's' appears as a subsequence of 't' after inserting exactly one character into 't'. The inserted character must be equal to a character in 's'.
#1. Maximum Number of Subsequences After One Inserting
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.
#2. Binary Tree Cameras
Imagine you're watering a garden using strategically placed taps. Find the fewest taps you need to open to water the entire garden, given each tap's watering range.
#3. Minimum Number of Taps to Open to Water a Garden
Determine if a string matches a pattern containing wildcard characters '?' (matches any single character) and '*' (matches any sequence of characters, including the empty sequence).
#4. Wildcard Matching
You are given an array of numbers. Determine the minimum total cost to remove all elements, where the cost of removing a subarray is the maximum value in that subarray.
#5. Find Minimum Cost to Remove Array Elements
Imagine repeating an array infinitely. Find the smallest subarray within this infinite array that sums up to a given target value, using elements from the original array.
#6. Minimum Size Subarray in Infinite Array
You are given two arrays of numbers. Find a subsequence of the same length from both arrays that maximizes their 'score', calculated by summing one subsequence and multiplying it by the minimum of the other.
#7. Maximum Subsequence Score
Given a string of digits, return all possible letter combinations that the number could represent, using the typical phone keypad mapping. The goal is to generate all valid combinations in any order.
#8. Letter Combinations of a Phone Number
You're given a tree where each node has coins. You need to collect coins from all nodes while maximizing your total points, considering that collecting from a node affects its children's coin values.
#9. Maximum Points After Collecting Coins From All Nodes
Find the minimum cost to traverse a weighted graph from a starting node to a destination node. You're given the graph's structure and edge costs, and need to determine the cheapest path.
#10. Minimum Cost Walk in Weighted Graph
Find the number of subarrays in a given array whose bitwise AND equals a specific target value, K.
#11. Number of Subarrays With AND Value of K
You are given bags of magic beans, each with a different number of beans. Find the minimum number of beans you need to remove so that all bags have the same number of beans.
#12. Removing Minimum Number of Magic Beans
You're given an array of numbers and a target sum 'k'. Find the maximum number of pairs within the array that add up to 'k'.
#13. Max Number of K-Sum Pairs
Two players alternate picking digits from a string. The goal is to determine if the sum of digits taken by the first player can always be made different from the sum of digits taken by the second player, assuming both play optimally.
#14. Sum Game
A tourist visits locations with associated points. Find the maximum total points the tourist can earn by visiting locations subject to travel time constraints between them.
#15. Maximum Points Tourist Can Earn
You are given two arrays. Sort the first array based on the order of elements in the second array. Elements not present in the second array should be appended to the end in ascending order.
#16. Relative Sort Array
You are given piles of gifts and a number of rounds. In each round, you take gifts from the richest pile (highest value) and reduce it by its square root. Return the total number of gifts remaining after all rounds.
#17. Take Gifts From the Richest Pile
Find the largest possible sum of elements from an array, where the sum is divisible by three.
#18. Greatest Sum Divisible by Three
Simulate a bowling game between two players. Determine the winner based on special strike rules that can double the score of subsequent throws.
#19. Determine the Winner of a Bowling Game
You're given a string and an integer k. Find the minimum number of characters you need to delete from the string so that every character appears either 0 times or exactly k times.
#20. Minimum Deletions to Make String K-Special