All Posts

Leetcode 731: My Calendar II

You are implementing a calendar system where you can add events. Each event is represented by a start time and an end time, defined as a half-open interval [startTime, endTime). You need to ensure that no more than two events overlap at any given time, or else return false. Your task is to implement a class, MyCalendarTwo, that will book events while preventing triple bookings.

Leetcode 744: Find Smallest Letter Greater Than Target

You are given a sorted array letters containing lowercase English letters and a character target. Return the smallest character in letters that is lexicographically greater than target. If no such character exists, return the first character in letters.

Leetcode 754: Reach a Number

You are standing at position 0 on an infinite number line. There is a destination at position target. You can make some number of moves where, on the i-th move, you take exactly i steps either left or right. The goal is to determine the minimum number of moves required to reach the target.

Leetcode 786: K-th Smallest Prime Fraction

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.

Leetcode 792: Number of Matching Subsequences

You are given a string s and an array of strings words. Your task is to determine how many words from the array are subsequences of the string s. A subsequence of a string is derived by deleting some or no characters from the original string without altering the order of the remaining characters.

Leetcode 825: Friends Of Appropriate Ages

You are given an integer array ages, where each element represents the age of a person on a social media platform. A person will not send a friend request to another person if any of the following conditions are true:

  1. The recipient’s age is less than or equal to half of the sender’s age plus 7.
  2. The recipient’s age is greater than the sender’s age.
  3. The recipient’s age is greater than 100 and the sender’s age is less than 100.

Otherwise, the sender can send a friend request. Return the total number of friend requests made between people.