Skip to content

Commit 2505c78

Browse files
authored
2025-01-28 v. 8.3.1: added "1111. Maximum Nesting Depth of Two Valid Parentheses Strings"
2 parents b1384cf + ee1a786 commit 2505c78

File tree

4 files changed

+41
-1
lines changed

4 files changed

+41
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,7 @@ Profile on LeetCode: [fartem](https://leetcode.com/fartem/).
663663
| 1079. Letter Tile Possibilities | [Link](https://leetcode.com/problems/letter-tile-possibilities/) | [Link](./lib/medium/1079_letter_tile_possibilities.rb) | [Link](./test/medium/test_1079_letter_tile_possibilities.rb) |
664664
| 1081. Smallest Subsequence of Distinct Characters | [Link](https://leetcode.com/problems/smallest-subsequence-of-distinct-characters/) | [Link](./lib/medium/1081_smallest_subsequence_of_distinct_characters.rb) | [Link](./test/medium/test_1081_smallest_subsequence_of_distinct_characters.rb) |
665665
| 1110. Delete Nodes And Return Forest | [Link](https://leetcode.com/problems/delete-nodes-and-return-forest/) | [Link](./lib/medium/1110_delete_nodes_and_return_forest.rb) | [Link](./test/medium/test_1110_delete_nodes_and_return_forest.rb) |
666+
| 1111. Maximum Nesting Depth of Two Valid Parentheses Strings | [Link](https://leetcode.com/problems/maximum-nesting-depth-of-two-valid-parentheses-strings/) | [Link](./lib/medium/1111_maximum_nesting_depth_of_two_valid_parentheses_strings.rb) | [Link](./test/medium/test_1111_maximum_nesting_depth_of_two_valid_parentheses_strings.rb) |
666667
| 1400. Construct K Palindrome Strings | [Link](https://leetcode.com/problems/construct-k-palindrome-strings/) | [Link](./lib/medium/1400_construct_k_palindrome_strings.rb) | [Link](./test/medium/test_1400_construct_k_palindrome_strings.rb) |
667668
| 2116. Check if a Parentheses String Can Be Valid | [Link](https://leetcode.com/problems/check-if-a-parentheses-string-can-be-valid/) | [Link](./lib/medium/2116_check_if_a_parentheses_string_can_be_valid.rb) | [Link](./test/medium/test_2116_check_if_a_parentheses_string_can_be_valid.rb) |
668669
| 2425. Bitwise XOR of All Pairings | [Link](https://leetcode.com/problems/bitwise-xor-of-all-pairings/) | [Link](./lib/medium/2425_bitwise_xor_of_all_pairings.rb) | [Link](./test/medium/test_2425_bitwise_xor_of_all_pairings.rb) |

leetcode-ruby.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ require 'English'
55
::Gem::Specification.new do |s|
66
s.required_ruby_version = '>= 3.0'
77
s.name = 'leetcode-ruby'
8-
s.version = '8.3.0'
8+
s.version = '8.3.1'
99
s.license = 'MIT'
1010
s.files = ::Dir['lib/**/*.rb'] + %w[README.md]
1111
s.executable = 'leetcode-ruby'
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# frozen_string_literal: true
2+
3+
# https://leetcode.com/problems/maximum-nesting-depth-of-two-valid-parentheses-strings/
4+
# @param {String} seq
5+
# @return {Integer[]}
6+
def max_depth_after_split(seq)
7+
result = ::Array.new(seq.size)
8+
9+
seq.each_char.with_index do |char, i|
10+
result[i] = char == '(' ? i & 1 : 1 - (i & 1)
11+
end
12+
13+
result
14+
end
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# frozen_string_literal: true
2+
3+
require_relative '../test_helper'
4+
require_relative '../../lib/medium/1111_maximum_nesting_depth_of_two_valid_parentheses_strings'
5+
require 'minitest/autorun'
6+
7+
class MaximumNestingDepthOfTwoValidParenthesesStringsTest < ::Minitest::Test
8+
def test_default_one
9+
assert_equal(
10+
[0, 1, 1, 1, 1, 0],
11+
max_depth_after_split(
12+
'(()())'
13+
)
14+
)
15+
end
16+
17+
def test_default_two
18+
assert_equal(
19+
[0, 0, 0, 1, 1, 0, 0, 0],
20+
max_depth_after_split(
21+
'()(())()'
22+
)
23+
)
24+
end
25+
end

0 commit comments

Comments
 (0)