You are given two arrays, tops and bottoms, where each array represents the top and bottom halves of a series of dominoes. A domino can be rotated, which means swapping its top and bottom halves. The task is to determine the minimum number of rotations required to make either the entire top row or the bottom row consist of the same value. If it is not possible to achieve this, return -1.
You are given an array representing the preorder traversal of a binary search tree (BST). Your task is to construct the BST from this preorder traversal and return the root of the tree.
You are given an array where each element represents the duration of a song in seconds. Your task is to count how many pairs of songs have a total duration that is divisible by 60. Specifically, you need to count how many pairs of songs, indexed as i and j (with i < j), satisfy the condition (time[i] + time[j]) % 60 == 0.
You are tasked with shipping packages using a ship with a limited weight capacity. Each package has a given weight and must be shipped in order within a specified number of days. Your objective is to determine the minimum weight capacity of the ship that allows all the packages to be shipped within the given days, without exceeding the ship’s weight capacity on any single day.
You are given an array where each element represents the value of a sightseeing spot. The distance between two sightseeing spots is the difference in their indices. The score of a pair of sightseeing spots i and j (where i < j) is calculated as values[i] + values[j] + (i - j), which includes the values of both spots and subtracts the distance between them. Your task is to find the maximum score of any pair of sightseeing spots.