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:

  1. Initially, the permutation P is [1, 2, 3, ..., m].
  2. For each queries[i], find the index of queries[i] in the permutation P.
  3. After locating queries[i] in P, move it to the beginning of the list.
  4. Return the list of indices (positions) for each element in queries as they are processed.

Leetcode 1410: HTML Entity Parser

You are tasked with decoding a string that contains HTML entities. The HTML entities represent special characters like quotation marks, ampersands, greater-than signs, etc. You need to replace the HTML entities with their respective characters.

Leetcode 1414: Find the Minimum Number of Fibonacci Numbers Whose Sum Is K

You are given an integer k, and you need to determine the minimum number of Fibonacci numbers whose sum equals k. Note that the same Fibonacci number can be used multiple times. The Fibonacci sequence is defined as F1 = 1, F2 = 1, and Fn = Fn-1 + Fn-2 for n > 2.