All Posts

Leetcode 1353: Maximum Number of Events That Can Be Attended

You are given a list of events where each event is represented by a pair [startDay, endDay]. Your task is to find the maximum number of events you can attend, ensuring that you attend only one event per day.

Leetcode 1382: Balance a Binary Search Tree

Given the root of a binary search tree (BST), return a balanced BST containing the same node values. A balanced BST is one where the depth of the left and right subtrees of every node never differ by more than 1.

Leetcode 1386: Cinema Seat Allocation

A cinema has multiple rows, each with ten seats arranged in a line. Some seats are already reserved. You need to determine the maximum number of four-person groups that can be seated in the available seats. A four-person group requires four adjacent seats in one row. If an aisle splits a group in the middle, they can still be seated if there are two consecutive seats on both sides of the aisle.

Leetcode 1400: Construct K Palindrome Strings

You are given a string s and an integer k. Your task is to determine whether it’s possible to use all the characters in the string s to construct exactly k palindromic strings.

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 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.