All Posts

Leetcode 1031: Maximum Sum of Two Non-Overlapping Subarrays

You are given an array of integers nums and two integers firstLen and secondLen. Your task is to find the maximum sum of elements from two non-overlapping subarrays of lengths firstLen and secondLen. The subarrays can appear in any order, but they must not overlap.

Leetcode 1034: Coloring A Border

You are given an m x n grid of integers where each value represents the color of a cell. You are also given three integers: row, col, and color. The task is to change the color of the border of the connected component containing the cell at grid[row][col]. A connected component is defined as a group of adjacent cells that have the same color. A border cell is a cell that is either adjacent to a different color cell or is on the boundary of the grid. You should return the updated grid where the border of the connected component is colored with the specified color.

Leetcode 1035: Uncrossed Lines

Given two integer arrays, nums1 and nums2, we write the integers of both arrays on two separate horizontal lines. We can draw connecting lines between the elements of nums1 and nums2 if they are equal and the lines do not intersect. The objective is to return the maximum number of connecting lines that can be drawn between the two arrays without any line intersecting.

Leetcode 1039: Minimum Score Triangulation of Polygon

Given an integer array representing the values at the vertices of a convex polygon, you need to triangulate the polygon in such a way that the sum of the products of the values at the vertices of all triangles is minimized. Each triangle must consist of three vertices of the polygon, and the number of triangles will always be n - 2, where n is the number of vertices in the polygon.

Leetcode 1040: Moving Stones Until Consecutive II

You are given a list of stones placed at different positions along the X-axis. A stone is considered an endpoint if it has the smallest or largest position. In one move, you can pick an endpoint stone and move it to any unoccupied position. The game ends when no more moves are possible, which occurs when the stones are in three consecutive positions. The goal is to find the minimum and maximum number of moves that can be made to achieve this configuration.

Leetcode 1043: Partition Array for Maximum Sum

Given an array of integers, partition the array into contiguous subarrays where each subarray has a length of at most k. After partitioning, transform each subarray such that all its elements are replaced by the maximum element of that subarray. Your goal is to return the maximum sum of the transformed array.