All Posts

Leetcode 2549: Count Distinct Numbers on Board

You are given a positive integer n, initially placed on a board. For each number x on the board, find all integers i such that 1 <= i <= n and x % i == 1. Add these numbers to the board. Your goal is to determine how many distinct integers will be present on the board after a billion days.

Leetcode 2553: Separate the Digits in an Array

You are given an array nums consisting of positive integers. Your task is to return a new array where each integer from nums is separated into its individual digits, while maintaining the order of the integers.

Leetcode 2554: Maximum Number of Integers to Choose From a Range I

You are given an array banned consisting of integers, an integer n, and an integer maxSum. Your task is to return the maximum number of integers you can select from the range [1, n] such that none of them are in the banned list and their sum does not exceed maxSum.

Leetcode 2555: Maximize Win From Two Segments

You are given a sorted array prizePositions containing positions of prizes along a line and an integer k. Your task is to select two segments of length k such that you can maximize the number of prizes collected. The two segments may overlap, and you can collect all prizes within either of the segments.

Leetcode 2556: Disconnect Path in a Binary Matrix by at Most One Flip

You are given a binary matrix grid where you can move from any cell (row, col) to adjacent cells (row + 1, col) or (row, col + 1) only if they have the value 1. The grid is disconnected if there is no path from the top-left corner (0, 0) to the bottom-right corner (m - 1, n - 1). You are allowed to flip at most one cell (changing a 1 to 0 or vice versa), but you cannot flip the cells (0, 0) or (m - 1, n - 1). Return true if it is possible to disconnect the grid by flipping at most one cell, otherwise return false.

Leetcode 2558: Take Gifts From the Richest Pile

You are given an integer array gifts where each element represents the number of gifts in different piles. Every second, you pick the pile with the most gifts and leave behind the floor of the square root of the number of gifts. Repeat this operation for k seconds, and return the total number of gifts left in all piles.