All Posts
Leetcode 1758: Minimum Changes To Make Alternating Binary String
s
consisting only of the characters ‘0’ and ‘1’. The string is considered alternating if no two adjacent characters are the same. Your task is to determine the minimum number of operations needed to make the string alternating, where in one operation, you can change any ‘0’ to ‘1’ or vice versa.
You are given a string Leetcode 1759: Count Number of Homogenous Substrings
s
consisting of lowercase letters, your task is to find the total number of homogenous substrings in s
. A homogenous substring is a substring where all characters are the same. Since the result could be very large, return the total modulo 10^9 + 7.
Given a string Leetcode 1763: Longest Nice Substring
A string is considered nice if every letter that appears in the string appears both in uppercase and lowercase. For example, ‘aA’ and ‘bB’ are nice strings, but ‘a’ and ‘B’ are not. Given a string s, find the longest nice substring of s. If there are multiple longest nice substrings, return the one that appears first. If no nice substring exists, return an empty string.
Leetcode 1768: Merge Strings Alternately
word1
and word2
. Merge the two strings by alternating their letters, starting with the first letter of word1
. If one string is longer, append the remaining characters of the longer string to the end of the merged string. Return the resulting merged string.
You are given two strings Leetcode 1769: Minimum Number of Operations to Move All Balls to Each Box
boxes
of length n
, where each character represents whether a box is empty (‘0’) or contains a ball (‘1’). Your task is to calculate, for each box, the minimum number of operations required to move all the balls to that particular box. An operation involves moving a ball from one box to an adjacent box.
You are given a binary string Leetcode 1773: Count Items Matching a Rule
You are given an array items
, where each items[i]
represents the type, color, and name of the ith item. You are also given a rule consisting of two strings: ruleKey
and ruleValue
. The task is to count how many items match the rule. An item matches the rule if one of the following conditions is true:
ruleKey == 'type'
andruleValue
matches the type of the item.ruleKey == 'color'
andruleValue
matches the color of the item.ruleKey == 'name'
andruleValue
matches the name of the item.