All Posts

Leetcode 2235: Add Two Integers

Given two integers, calculate and return their sum.

Leetcode 2236: Root Equals Sum of Children

You are given a binary tree with three nodes: the root, its left child, and its right child. Determine whether the value of the root node is equal to the sum of the values of its two children.

Leetcode 2239: Find Closest Number to Zero

Given an array of integers, find the number closest to 0. If there are multiple numbers equally close, return the largest number among them.

Leetcode 2243: Calculate Digit Sum of a String

You are given a string of digits, s, and an integer k. Your task is to repeatedly process the string until its length becomes less than or equal to k. In each step, divide the string into consecutive groups of size k. If the last group is smaller than k, process it as is. For each group, calculate the sum of its digits, convert the result back to a string, and merge all groups to form a new string. Repeat the process until the string length is ≤ k, and return the final string.

Leetcode 2255: Count Prefixes of a Given String

Given a list of strings words and a target string s, count how many strings in words are prefixes of s. A prefix is defined as a substring starting from the beginning of a string and extending up to a given length. Note that duplicate strings in words should be counted separately.

Leetcode 2259: Remove Digit From Number to Maximize Result

You are given a string number representing a positive integer and a character digit. Your task is to remove exactly one occurrence of digit from the string number such that the resulting number, when interpreted as an integer, is maximized. The test cases are guaranteed to have at least one occurrence of digit in the string.