You operate a giant Ferris wheel with four gondolas, each holding up to four passengers. The Ferris wheel rotates counterclockwise and incurs a running cost for every rotation. You are given a list of customer arrivals, where each entry indicates the number of customers arriving just before the ith rotation. Customers board the gondola closest to the ground, and only a maximum of four customers can board at any time, while any excess wait for the next rotation. Each customer pays a boarding cost. Your task is to determine the minimum number of rotations needed to achieve the maximum profit. If there is no scenario where the profit is positive, return -1.
In a kingdom, there is a well-defined hierarchy of inheritance, starting with the king. The inheritance order depends on the family’s birth and death events. Implement a class to keep track of the order, excluding the dead members.
Employees use key-cards to unlock office doors, and the system records the time of each use. An alert is triggered if a worker uses their key-card three or more times within a one-hour period.
You are given two arrays representing the sum of elements in each row and each column of a 2D matrix. The rowSum[i] represents the sum of the elements in the i-th row, and colSum[j] represents the sum of the elements in the j-th column. Your task is to find a matrix of non-negative integers that satisfies these row and column sum requirements.
A binary tree is called Even-Odd if the values in each level of the tree follow certain rules. For every even-indexed level, all nodes must contain odd integers in strictly increasing order. For every odd-indexed level, all nodes must contain even integers in strictly decreasing order. Given the root of a binary tree, return true if the tree is Even-Odd, otherwise return false.
You are given a network of cities, where some cities are directly connected by bidirectional roads. The network rank between two cities is defined as the total number of roads connected to either of the cities. If a road connects both cities, it is only counted once. The task is to find the maximal network rank for any pair of distinct cities in the infrastructure.