Showing 38 questions
You're given your initial points and information about multiple enemy battles. Each battle can increase or decrease your points. Determine the maximum points you can have after strategically fighting a subset of the enemies.
#1. Maximum Points After Enemy Battles
Given an array, you can remove all occurrences of a single element. Find the maximum possible sum of a subarray after performing this removal.
#2. Maximize Subarray Sum After Removing All Occurrences of One Element
You're given the starting and target positions of multiple pieces on a grid. Find the sum of Manhattan distances for every possible arrangement of moving the pieces from their starting to target positions.
#3. Manhattan Distances of All Arrangements of Pieces
Determine if you can transform a grid of zeros to a target grid using a stamp of a given size. You can stamp multiple times, and the stamp must fit within the grid's boundaries.
#4. Stamping the Grid
You are given several circles defined by their center coordinates and radius. Your task is to count the number of distinct lattice points (points with integer coordinates) that lie inside or on the boundary of at least one of these circles.
#5. Count Lattice Points Inside a Circle
Alice and Bob are playing a game with flowers. Determine who wins based on the number of odd and even flower pots available.
#6. Alice and Bob Playing Flower Game
Simulate the Candy Crush game. Repeated sequences of the same candy type (3 or more) should be removed until no more such sequences exist.
#7. Candy Crush
You're given an array representing weights. Implement a function to randomly pick an index from the array, where the probability of picking each index is proportional to its weight.
#8. Random Pick with Weight
#9. Find X Value of Array I
You have a certain number of candies to distribute among children, but there are rules on how many each child can receive. Determine the number of ways to distribute all the candies following these constraints.
#10. Distribute Candies Among Children III
You have a certain number of candies to distribute among a given number of children. Find out how many children will receive the maximum number of candies.
#11. Distribute Candies Among Children I
Determine if a given string contains a substring where the reverse of that substring also exists within the original string.
#12. Existence of a Substring in a String and Its Reverse
Design a data structure that acts as a Least Recently Used (LRU) cache. Implement methods to get and put key-value pairs, evicting the least recently used entry when the cache is full.
#13. LRU Cache
Given an array of numbers, find all possible subsequences. Calculate the sum of each subsequence where each number is raised to the power of its position in the subsequence.
#14. Find the Sum of Subsequence Powers
Given an array, you repeatedly choose two elements and replace one with their bitwise XOR. The goal is to minimize the remaining element after several operations.
#15. Find X Value of Array II
You have a certain number of candies to distribute among children. Each child has a limit to how many candies they can receive; distribute the candies as fairly as possible up to a given limit per child.
#16. Distribute Candies Among Children II
Find the length of the longest substring within a given string that appears at least three times, with the occurrences allowed to overlap. The substring must also consist of only one distinct character.
#17. Find Longest Special Substring That Occurs Thrice II
Design a data structure that supports insert, delete, and getRandom operations, all in average O(1) time. The getRandom method should return a random element from the current set of elements.
#18. Insert Delete GetRandom O(1)
Implement a multithreaded web crawler to efficiently explore and retrieve pages from a website, respecting the website's rules.
#19. Web Crawler Multithreaded
Implement a snapshot array where you can update elements and take snapshots of the array at any time. Later, you should be able to retrieve the value of an element at a specific snapshot.
#20. Snapshot Array