1. Shortest Route with Required Stop
Given a set of roads connecting nodes, with each road having a certain length (weight), find the shortest route from node a to node b that must pass through node c. If there is no such path, return -1. For example, given roads_nodes=4, m=3, a=1, b=3, c=2, and arrays roads_from=[0, 0, 0], roads_to=[2, 1, 3], roads_weight=[1, 2, 3], determine the shortest route from a to b via c.
2. Energy Layer Breach Game
Given n layers of a system's protection, each with a cost of layer[i] units of energy to breach, an array energy representing the energy reserve after breaching each layer, and an integer k representing the initial energy reserve, calculate the number of points an attacker can score. A point is awarded if, after breaching a layer, the remaining energy reserve is at least as much as the energy required for that layer. Starting from each level i from 1 to n, find the number of points that the attacker can score. For example, given n=3, layers=[5, 8, 11], energy=[4, 2, 1], and k=10, determine the points scored starting from each level.
3. Image Processing Plan Cost Optimization
Given n filters, afterCost (an array representing the cost of applying each filter after its designated processing period), startDay (an array representing the start day of the processing period for each filter), endDay (an array representing the end day of the processing period for each filter), and discountPrice (a number representing the discount applied to the cost of filters after their designated processing period), devise an image processing plan that adheres to time constraints and minimizes costs. Return the minimum cost. For example, given n=3, afterCost=[2, 3, 4], startDay=[1, 2], endDay=[2, 3], and discountPrice=6, determine the minimum cost to apply all filters within their designated processing periods.
4. Store Price Adjustment Based on Queries
A store adjusts the prices of its items based on inflation through two types of queries. Implement a function that takes an array of item prices, the number of items n, and an array of queries. Each query can change the price of an item to a new value or adjust all prices below a certain value to that value. The function should apply the queries and return the final prices of all items.
5. Maze Shortest Path for Collecting Objects
Bob and Alice are in a maze where Bob needs to collect all gold coins and deliver them to Alice's position. The maze is represented by an n x m array with different values indicating open, blocked, and gold coin cells. Bob starts at the top left cell (0, 0), and Alice's position is given by coordinates (x, y). Implement an algorithm to determine the shortest path Bob can follow to collect all gold coins and deliver them to Alice. If it's not possible, the function should return -1.