All Posts
Leetcode 1663: Smallest String With A Given Numeric Value
You are given two integers n
and k
. Your task is to return the lexicographically smallest string of length n
with a numeric value equal to k
. The numeric value of a string is the sum of the numeric values of its characters, where ‘a’ = 1, ‘b’ = 2, …, and ‘z’ = 26.
Leetcode 1673: Find the Most Competitive Subsequence
Given an integer array nums
and a positive integer k
, return the most competitive subsequence of nums
of size k
. A subsequence is more competitive than another if at the first position where they differ, the subsequence has a smaller number.
Leetcode 1686: Stone Game VI
Alice and Bob take turns playing a game with a pile of n
stones, each having a value assigned by both players. They play optimally and aim to maximize their total points by choosing stones with the highest value for each player.
Leetcode 1702: Maximum Binary String After Change
You are given a binary string consisting of only ‘0’s and ‘1’s. You can perform two types of operations on this string any number of times:
- Operation 1: Replace any occurrence of the substring ‘00’ with ‘10’.
- Operation 2: Replace any occurrence of the substring ‘10’ with ‘01’.
Your goal is to apply these operations and transform the binary string into the largest possible binary string in terms of its decimal value. A string ‘x’ is considered larger than string ‘y’ if the decimal value of ‘x’ is greater than that of ‘y’.
Leetcode 1705: Maximum Number of Eaten Apples
You have a special apple tree that grows apples for ’n’ days. On each day ‘i’, the tree grows ‘apples[i]’ apples, which rot after ‘days[i]’ days. That means, apples grown on day ‘i’ will rot after ‘i + days[i]’. You can eat at most one apple per day, and you can continue eating after the first ’n’ days. You want to know the maximum number of apples you can eat.
Leetcode 1717: Maximum Score From Removing Substrings
You are given a string s
and two integers x
and y
. You can perform two types of operations any number of times:
- Remove the substring “ab” and gain
x
points. - Remove the substring “ba” and gain
y
points.
Each time a substring is removed, the characters are deleted from the string, and the corresponding points are added to your total score. Your task is to maximize the total score after applying these operations any number of times.