[Problem URL](https://leetcode.com/problems/minimum-one-bit-operations-to-make-integers-zero/?envType=daily-question&envId=2023-11-30)
Given an integer n, transform it into 0 using the following operations:
- Change the rightmost (0th) bit in the binary representation of n.
- Change the ith bit in the binary representation of n if the (i-1)th bit is set to 1 and the (i-2)th through 0th bits are set to 0.
Return the minimum number of operations to transform n into 0.
#### Example 1:
Input: n = 3
Output: 2
Explanation:
The binary representation of 3 is "11".
- "11" -> "01" with the 2nd operation since the 0th bit is 1.
- "01" -> "00" with the 1st operation.
#### Example 2:
Input: n = 6
Output: 4
Explanation:
The binary representation of 6 is "110".
- "110" -> "010" with the 2nd operation since the 1st bit is 1 and 0th through 0th bits are 0.
- "010" -> "011" with the 1st operation.
- "011" -> "001" with the 2nd operation since the 0th bit is 1.
- "001" -> "000" with the 1st operation.
#### Constraints:
0 <= n <= 10^9
Given an integer n, transform it into 0 using the following operations:
- Change the rightmost (0th) bit in the binary representation of n.
- Change the ith bit in the binary representation of n if the (i-1)th bit is set to 1 and the (i-2)th through 0th bits are set to 0.
Return the minimum number of operations to transform n into 0.
#### Example 1:
Input: n = 3
Output: 2
Explanation:
The binary representation of 3 is "11".
- "11" -> "01" with the 2nd operation since the 0th bit is 1.
- "01" -> "00" with the 1st operation.
#### Example 2:
Input: n = 6
Output: 4
Explanation:
The binary representation of 6 is "110".
- "110" -> "010" with the 2nd operation since the 1st bit is 1 and 0th through 0th bits are 0.
- "010" -> "011" with the 1st operation.
- "011" -> "001" with the 2nd operation since the 0th bit is 1.
- "001" -> "000" with the 1st operation.
#### Constraints:
0 <= n <= 10^9
Problem URL: [Check if Two String Arrays are Equivalent](https://leetcode.com/problems/check-if-two-string-arrays-are-equivalent/?envType=daily-question&envId=2023-12-01)
Text:
Given two string arrays
A string is represented by an array if the array elements concatenated in order forms the string.
Example 1:
Input:
-
-
Output:
Explanation:
-
-
- The strings are the same, so return
Example 2:
Input:
-
-
Output:
Example 3:
Input:
-
-
Output:
Constraints:
- 1 <=
- 1 <=
- 1 <= sum(
-
Text:
Given two string arrays
word1
and word2
, return true if the two arrays represent the same string, and false otherwise.A string is represented by an array if the array elements concatenated in order forms the string.
Example 1:
Input:
-
word1
= ["ab", "c"]
-
word2
= ["a", "bc"]
Output:
true
Explanation:
-
word1
represents string "ab" + "c" -> "abc"-
word2
represents string "a" + "bc" -> "abc"- The strings are the same, so return
true
.Example 2:
Input:
-
word1
= ["a", "cb"]
-
word2
= ["ab", "c"]
Output:
false
Example 3:
Input:
-
word1
= ["abc", "d", "defg"]
-
word2
= ["abcddefg"]
Output:
true
Constraints:
- 1 <=
word1.length
, word2.length
<= 10^3- 1 <=
word1[i].length
, word2[i].length
<= 10^3- 1 <= sum(
word1[i].length
), sum(word2[i].length
) <= 10^3-
word1[i]
and word2[i]
consist of lowercase letters.Today is a first day of https://adventofcode.com/2023/day/1, great opportunity to learn some new language. I will be solving it in Rust https://github.com/samoylenkodmitry/AdventOfCode_2023
GitHub
GitHub - samoylenkodmitry/AdventOfCode_2023: my advent of code 2023 solutions
my advent of code 2023 solutions. Contribute to samoylenkodmitry/AdventOfCode_2023 development by creating an account on GitHub.
#### Problem
We are given an array of strings
#### Example 1
- Input:
-
-
- Output:
- Explanation: The "good" strings that can be formed are "cat" and "hat", so the answer is
#### Example 2
- Input:
-
-
- Output:
- Explanation: The "good" strings that can be formed are "hello" and "world", so the answer is
#### Constraints
-
-
-
#### Problem URL
[Problem URL](https://leetcode.com/problems/find-words-that-can-be-formed-by-characters/?envType=daily-question&envId=2023-12-02)
We are given an array of strings
words
and a string chars
. A string is considered "good" if it can be formed using characters from chars
, with each character used only once. We need to find the sum of the lengths of all "good" strings in words
.#### Example 1
- Input:
-
words = ["cat","bt","hat","tree"]
-
chars = "atach"
- Output:
6
- Explanation: The "good" strings that can be formed are "cat" and "hat", so the answer is
3 + 3 = 6
.#### Example 2
- Input:
-
words = ["hello","world","leetcode"]
-
chars = "welldonehoneyr"
- Output:
10
- Explanation: The "good" strings that can be formed are "hello" and "world", so the answer is
5 + 5 = 10
.#### Constraints
-
1 <= words.length <= 1000
-
1 <= words[i].length, chars.length <= 100
-
words[i]
and chars
consist of lowercase English letters.#### Problem URL
[Problem URL](https://leetcode.com/problems/find-words-that-can-be-formed-by-characters/?envType=daily-question&envId=2023-12-02)