All Posts

Leetcode 816: Ambiguous Coordinates

You are given a string s representing coordinates that have been encoded by removing commas, decimal points, and spaces. Your task is to restore the coordinates to their original form by considering all possible valid ways the digits could be split into two parts: a left part representing the x-coordinate and a right part representing the y-coordinate. Both parts may optionally contain a decimal point. The final coordinates must follow specific rules: no leading zeros are allowed, and the decimal point must be placed correctly. Return a list of all possible valid coordinates, formatted as ‘(x, y)’, where x and y represent the respective coordinates.

Leetcode 845: Longest Mountain in Array

Given an integer array arr, you need to find the length of the longest subarray that forms a mountain. A mountain subarray has the following properties: it must have at least three elements, the elements strictly increase to a peak, and then strictly decrease after the peak. If no such subarray exists, return 0.

Leetcode 869: Reordered Power of 2

Given an integer n, check if it is possible to reorder its digits (in any order, including the original order) to form a number that is a power of two. Leading digits cannot be zero in the reordered number.

Leetcode 949: Largest Time for Given Digits

Given an array of 4 digits, your task is to form the latest possible 24-hour time using each digit exactly once. The time is represented in the format ‘HH:MM’ where ‘HH’ is between 00 and 23, and ‘MM’ is between 00 and 59. If no valid time can be formed, return an empty string.

Leetcode 970: Powerful Integers

Given three integers x, y, and bound, find all powerful integers that are less than or equal to bound. A powerful integer can be expressed in the form x^i + y^j for non-negative integers i and j. Return the results as a list with no duplicates, and the order of the elements does not matter.

Leetcode 1620: Coordinate With Maximum Network Quality

You are given an array of network towers, where each tower is represented by a list [xi, yi, qi] denoting its location (xi, yi) on the X-Y plane and its quality factor qi. You are also given a radius, and a tower is considered reachable if the distance between the tower and a coordinate is less than or equal to the radius. The signal quality of a tower at a coordinate (x, y) is calculated using the formula ⌊qi / (1 + d)⌋, where d is the Euclidean distance between the tower and the coordinate. The total network quality at a coordinate is the sum of the signal qualities from all the reachable towers. Your task is to find the coordinate with the maximum network quality. If multiple coordinates have the same network quality, return the lexicographically smallest coordinate.