All Posts

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 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.

Leetcode 2562: Find the Array Concatenation Value

You are given an array of integers, nums, and you need to calculate the total concatenation value. To calculate this, you repeatedly perform the following operations until the array is empty:

  1. If the array has more than one element, take the first and last elements, concatenate them, and add the result to the total concatenation value. Then remove the first and last elements from the array.
  2. If the array has only one element, add it to the total concatenation value and remove the element.

The goal is to return the total concatenation value after performing all the operations.

Leetcode 2582: Pass the Pillow

You are given the root of a binary tree and a positive integer k. The level sum in the tree is the sum of the node values that lie at the same level. Return the kth largest level sum in the tree. If there are fewer than k levels, return -1. Nodes are on the same level if they are at the same distance from the root.

Leetcode 2593: Find Score of an Array After Marking All Elements

You are given an array nums consisting of positive integers. Starting with a score = 0, repeatedly select the smallest unmarked integer, add its value to the score, and mark it along with its adjacent elements (if any). Continue this until all elements are marked, then return the final score.

Leetcode 2596: Check Knight Tour Configuration

Given an n x n chessboard, the knight starts at the top-left corner and visits every cell exactly once. The knight’s movements are represented by a grid where grid[row][col] indicates the order of the knight’s visit to that cell. Determine if this sequence of moves is valid, i.e., the knight moves according to its legal movement pattern.