All Posts

Leetcode 1248: Count Number of Nice Subarrays

You are given an array of integers nums and an integer k. A subarray is considered ’nice’ if it contains exactly k odd numbers. Your task is to return the number of nice subarrays in the given array.

Leetcode 1253: Reconstruct a 2-Row Binary Matrix

You are given a binary matrix with 2 rows and n columns, where each element is either 0 or 1. The sum of elements in the 0-th (upper) row is given by upper, the sum of elements in the 1-st (lower) row is given by lower, and the column-wise sum is given by colsum. Your task is to reconstruct the matrix based on these sums. If reconstruction is not possible, return an empty matrix.

Leetcode 1254: Number of Closed Islands

You are given a 2D grid with 0s (land) and 1s (water). An island is a group of 0s connected 4-directionally, and a closed island is a group of 0s completely surrounded by 1s. Your task is to count how many closed islands are present in the grid.

Leetcode 1262: Greatest Sum Divisible by Three

Given an array of integers, find the maximum sum of any subsequence where the sum is divisible by 3.

Leetcode 1266: Minimum Time Visiting All Points

You are given an array of points with integer coordinates. Calculate the minimum time to visit all points in the given order using vertical, horizontal, or diagonal movements.

Leetcode 1267: Count Servers that Communicate

You are given a 2D grid where each cell is either 1 (indicating a server) or 0 (no server). Two servers are said to communicate if they are in the same row or column. The task is to find the number of servers that can communicate with at least one other server.