All Posts

Leetcode 1844: Replace All Digits with Characters

You are given a string s with lowercase English letters at even indices and digits at odd indices. For each odd index i, replace the digit s[i] with the result of the operation shift(s[i-1], s[i]), where shift(c, x) returns the xth character after c. Return the modified string after replacing all digits.

Leetcode 1848: Minimum Distance to the Target Element

You are given an array nums, along with two integers target and start. Your task is to find an index i such that nums[i] == target, and the absolute difference between i and start is minimized. Return abs(i - start), where abs(x) is the absolute value of x.

Leetcode 1854: Maximum Population Year

You are given a 2D array logs where each entry represents the birth and death years of a person. You need to determine the earliest year that has the maximum population, where population is defined as the number of people alive in a given year.

Leetcode 1859: Sorting the Sentence

You are given a shuffled sentence where each word is tagged with a number that represents its position in the original sentence. Your task is to reconstruct the sentence in its original order and return it.

Leetcode 1863: Sum of All Subset XOR Totals

You are given an array of integers nums. The XOR total of an array is defined as the bitwise XOR of all its elements, or 0 if the array is empty. For every subset of nums, calculate the XOR total and return the sum of all XOR totals.

Leetcode 1869: Longer Contiguous Segments of Ones than Zeros

You are given a binary string s. Your task is to determine whether the longest contiguous segment of 1’s is strictly longer than the longest contiguous segment of 0’s. Return true if this condition holds, otherwise return false.