All Posts

Leetcode 763: Partition Labels

You are given a string s. Your task is to divide the string into the maximum number of parts such that each letter appears in at most one part. The resulting parts, when concatenated in order, should form the original string.

Leetcode 767: Reorganize String

You are given a string s consisting of lowercase English letters. The task is to rearrange the characters of the string such that no two adjacent characters are the same. Return any valid rearrangement of the string, or return an empty string if it is not possible to rearrange the characters in such a way.

Leetcode 769: Max Chunks To Make Sorted

You are given an integer array arr of length n, where the array is a permutation of integers in the range [0, n - 1]. Your task is to split this array into as many chunks (or partitions) as possible, where each chunk can be individually sorted. After sorting each chunk, when concatenated, the result should be the same as the fully sorted array. Return the largest number of chunks that you can create to achieve the sorted array.

Leetcode 781: Rabbits in Forest

In a forest, there are an unknown number of rabbits. We ask n rabbits, ‘How many rabbits of the same color as you are there?’ and collect their answers in an integer array answers, where answers[i] is the answer of the i-th rabbit. The task is to determine the minimum number of rabbits that could be in the forest.

Leetcode 807: Max Increase to Keep City Skyline

In a city grid, buildings are represented by an n x n matrix where each element corresponds to the height of a building at a specific location. You can increase the height of any building in the city grid, but the increased height should not alter the skyline of the city when viewed from any of the four cardinal directions (north, south, east, and west). Your task is to calculate the maximum sum of the heights that can be added to the buildings without changing the skyline.

Leetcode 826: Most Profit Assigning Work

You are given a list of jobs, each with a difficulty level and a profit value, and a list of workers, each with a certain ability. A worker can only complete jobs with a difficulty level that is at most equal to the worker’s ability. Each worker can complete at most one job, but jobs can be assigned to multiple workers. The goal is to calculate the maximum total profit by assigning the jobs to workers based on their abilities.