All Posts

Leetcode 2390: Removing Stars From a String

You are given a string s that contains lowercase English letters and stars (*). In each operation, you can choose a star in s, remove the closest non-star character to its left, and remove the star itself. Perform this operation until all stars are removed and return the resulting string.

Leetcode 2434: Using a Robot to Print the Lexicographically Smallest String

You are given a string s and a robot that starts with an empty string t. The robot can perform two operations: one, it can remove the first character of string s and append it to t, and two, it can remove the last character of string t and write it down. The goal is to return the lexicographically smallest string that can be written on paper using these operations.

Leetcode 2487: Remove Nodes From Linked List

You are given the head of a linked list. Your task is to remove every node that has a node with a greater value to its right. The modified linked list should be returned after the removal of such nodes.

Leetcode 2645: Minimum Additions to Make Valid String

Given a string ‘word’ consisting of letters ‘a’, ‘b’, and ‘c’, you can insert letters ‘a’, ‘b’, or ‘c’ anywhere and as many times as needed. Your task is to determine the minimum number of insertions required to transform ‘word’ into a valid string. A string is considered valid if it can be formed by repeatedly concatenating the string ‘abc’.

Leetcode 2696: Minimum String Length After Removing Substrings

You are given a string s consisting of only uppercase English letters. You can repeatedly remove any occurrence of the substrings ‘AB’ or ‘CD’ from s. Each operation removes one of these substrings and shortens the string. After performing the operations, return the minimum possible length of the resulting string. Note that removing substrings can create new occurrences of ‘AB’ or ‘CD’, which can be removed in further operations.

Leetcode 2816: Double a Number Represented as a Linked List

You are given the head of a non-empty linked list representing a non-negative integer, where each node contains a single digit of the number. Your task is to double the integer represented by the linked list and return the resulting number as a new linked list.