You are given a string num, representing a large integer, and an integer k. Return the minimum number of adjacent swaps required to transform num into the k-th smallest wonderful integer that is greater than num and is a permutation of its digits.
You are given two non-increasing 0-indexed integer arrays nums1 and nums2. A pair of indices (i, j) is valid if both i <= j and nums1[i] <= nums2[j]. The distance of the pair is j - i. You need to return the maximum distance of any valid pair (i, j). If there are no valid pairs, return 0.
You are given two memory sticks with certain amounts of available memory. A program runs and allocates increasing amounts of memory to the stick with more available memory. If neither stick has enough memory to allocate the required amount, the program crashes. Determine when the program crashes and the remaining memory on each stick.
You are given an m x n matrix of characters box, where each cell is a stone (#), a stationary obstacle (*), or an empty space (.). After rotating the box 90 degrees clockwise, gravity will cause stones to fall down until they land on an obstacle, another stone, or the bottom. Return the updated matrix after the stones have fallen.
You are given two integer arrays nums1 and nums2. Your task is to implement a data structure that supports two types of operations: 1) Add a value to an element in nums2. 2) Count the number of pairs (i, j) such that nums1[i] + nums2[j] equals a given total value.
You are given a list of n train ride distances and a floating-point number hour which indicates the total time you have to reach your destination. You need to determine the minimum integer speed (in kilometers per hour) at which all the trains must travel to reach the office on time. If it is impossible, return -1.