All Posts

Leetcode 406: Queue Reconstruction by Height

You are given an array of people, where each person is represented by two integers: their height hi and the number of people ki in front of them who have a height greater than or equal to hi. Your task is to reconstruct the queue based on these attributes.

Leetcode 673: Number of Longest Increasing Subsequence

Given an integer array nums, return the number of distinct longest increasing subsequences.

Leetcode 729: My Calendar I

You are implementing a calendar application where you can add events. Each event has a start time and end time represented by a half-open interval [start, end). An event can only be added if it does not overlap with existing events in the calendar. Return true if the event can be booked successfully, and false if it causes a conflict.

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 1395: Count Number of Teams

You are given a list of soldiers, each with a unique rating. You need to form teams of 3 soldiers from this list. A valid team is one where the soldiers’ ratings are either strictly increasing or strictly decreasing as we move from left to right in the team. The team must satisfy the condition that the indices (i, j, k) follow 0 <= i < j < k < n.

Leetcode 2080: Range Frequency Queries

Design a data structure that allows you to efficiently find the frequency of a given value in a subarray. Implement the class RangeFreqQuery with the following methods:

  • RangeFreqQuery(int[] arr) initializes the data structure.
  • int query(int left, int right, int value) returns the frequency of value in the subarray from left to right.