All Posts

Leetcode 1996: The Number of Weak Characters in the Game

You are given a list of characters’ properties, where each character has two main attributes: attack and defense. A character is weak if another character exists with both greater attack and defense values. Return the number of weak characters in the list.

Leetcode 2104: Sum of Subarray Ranges

You are given an integer array nums. A subarray of nums is a contiguous sequence of elements. The range of a subarray is defined as the difference between the maximum and minimum elements within that subarray.

Your task is to calculate the sum of the ranges for all possible subarrays in the given array nums.

Leetcode 2487: Remove Nodes From Linked List

You are given the head of a linked list. Your task is to remove every node that has a node with a greater value to its right. The modified linked list should be returned after the removal of such nodes.

Leetcode 2865: Beautiful Towers I

You are given an array heights representing the number of bricks in n consecutive towers. Your task is to remove some bricks to form a mountain-shaped tower arrangement. In this arrangement, the tower heights are non-decreasing, reaching a maximum peak value with one or multiple consecutive towers and then non-increasing. Return the maximum possible sum of heights of a mountain-shaped tower arrangement.

Leetcode 2866: Beautiful Towers II

You are given an array maxHeights of n integers. Your task is to build n towers in the coordinate line where the height of the i-th tower is between 1 and maxHeights[i]. The configuration is beautiful if the heights form a mountain array, where heights increase to a peak and then decrease afterward. Return the maximum possible sum of the heights of a beautiful tower configuration.