All Posts

Leetcode 831: Masking Personal Information

You are given a string representing either an email address or a phone number. The task is to mask the personal information by following specific rules. For email addresses, the name and domain should be in lowercase, and the middle letters of the name should be replaced with asterisks. For phone numbers, any non-digit characters should be removed, and the number should be masked with asterisks based on the country code and local number.

Leetcode 833: Find And Replace in String

You are given a string s and k replacement operations. Each replacement operation consists of an index, a source substring, and a target substring. For each operation, check if the source substring occurs at the given index in s. If it does, replace the substring with the target. All operations are performed simultaneously, meaning they do not affect each other’s indexing. The task is to return the modified string after all operations are applied.

Leetcode 838: Push Dominoes

In a line of n dominoes, each domino is initially standing upright. Some dominoes are pushed either to the left or the right. Over time, falling dominoes will cause adjacent dominoes to fall in the same direction. If a domino is pushed from both sides, it remains standing. The task is to simulate the final state of the dominoes after all the forces are applied.

Leetcode 842: Split Array into Fibonacci Sequence

You are given a string of digits, and you need to split it into a sequence of integers that follow the Fibonacci-like property. In other words, the sum of the first two numbers should equal the third, the sum of the second and third should equal the fourth, and so on. Your goal is to find any valid Fibonacci-like sequence from the digits, or return an empty list if it’s not possible.

Leetcode 844: Backspace String Compare

You are given an integer array arr. A mountain array is an array where the elements first strictly increase to a peak and then strictly decrease after that peak. Your task is to find the length of the longest mountain subarray in the given array. If no such subarray exists, return 0.

Leetcode 848: Shifting Letters

You are given a string s of lowercase English letters and an array shifts, where shifts[i] represents the number of times to shift the first i + 1 characters of s. The shift operation for a letter means moving to the next letter in the alphabet, and if the letter is ‘z’, it wraps around to ‘a’. After applying all the shifts, return the final string.