You are given a sorted array of prime numbers and the number 1. You need to find the k-th smallest fraction formed by considering all possible fractions arr[i] / arr[j] where i < j. Return the k-th smallest fraction as an array of two integers, where arr[i] is the numerator and arr[j] is the denominator.
You are given a number of cities and a list of flights between them. Each flight has a price and connects two cities. You need to find the cheapest route from a given source city to a destination city with at most a certain number of stops. If no such route exists, return -1.
Given an integer n, find how many integers in the range [1, n] are ‘good’ integers. A number is considered ‘good’ if after rotating each of its digits by 180 degrees, it becomes a valid different number. The rotation rules for digits are as follows: 0, 1, and 8 stay the same, 2 and 5 swap places, 6 and 9 swap places, and other digits are not valid when rotated.
You are playing a simplified game on an infinite 2-D grid where you start at position [0, 0], and your goal is to reach a destination point target = [xtarget, ytarget]. There are several ghosts on the map, each with its starting position. You and the ghosts can all independently move one unit in any of the four cardinal directions (north, east, south, or west), or stay still. If you can reach the destination before any ghost catches up with you, you escape. You cannot escape if you reach any square at the same time as a ghost. Your task is to return true if it is possible to escape, otherwise return false.
You are given a 2 x n grid and two types of tiles: a 2 x 1 domino and a tromino (which can be rotated). You must cover the grid entirely with these tiles. The task is to find the number of possible ways to tile the 2 x n board, modulo 10^9 + 7. Each tile must cover exactly two adjacent squares, and every square must be covered by a tile.
You are given a string order that specifies a custom order of characters, and a string s that contains the characters you need to permute. The task is to rearrange the characters of s so that they follow the order specified in the string order. If a character appears in order, it must appear in s in the same relative order. Any characters from s that don’t appear in order can be arranged in any position.