All Posts
Leetcode 1401: Circle and Rectangle Overlapping
You are given a circle represented by its radius and center coordinates, as well as an axis-aligned rectangle represented by its bottom-left and top-right corners. Determine if the circle and the rectangle overlap, i.e., if there is any point inside both the circle and the rectangle.
Leetcode 1404: Number of Steps to Reduce a Number in Binary Representation to One
You are given a binary string representing a non-negative integer. The task is to determine the number of steps required to reduce this number to 1, following the rules: divide by 2 if the number is even, or add 1 if it is odd. Return the total number of steps required.
Leetcode 1405: Longest Happy String
You are given three integers, a, b, and c, representing the maximum occurrences of ‘a’, ‘b’, and ‘c’ that can appear in a string. Your task is to return the longest string that can be formed using these letters such that it does not contain the substrings ‘aaa’, ‘bbb’, or ‘ccc’. The string should contain at most a occurrences of ‘a’, at most b occurrences of ‘b’, and at most c occurrences of ‘c’.
Leetcode 1409: Queries on a Permutation With Key
You are given a list of positive integers called queries
, each between 1 and m
. You need to process each element in queries
sequentially according to the following rules:
- Initially, the permutation
P
is[1, 2, 3, ..., m]
. - For each
queries[i]
, find the index ofqueries[i]
in the permutationP
. - After locating
queries[i]
inP
, move it to the beginning of the list. - Return the list of indices (positions) for each element in
queries
as they are processed.