Skip to content

Commit

Permalink
2025-01-28 v. 8.3.1: added "1111. Maximum Nesting Depth of Two Valid …
Browse files Browse the repository at this point in the history
…Parentheses Strings"
  • Loading branch information
fartem authored Jan 28, 2025
2 parents b1384cf + ee1a786 commit 2505c78
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,7 @@ Profile on LeetCode: [fartem](https://leetcode.com/fartem/).
| 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) |
| 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) |
| 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) |
| 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) |
| 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) |
| 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) |
| 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) |
Expand Down
2 changes: 1 addition & 1 deletion leetcode-ruby.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ require 'English'
::Gem::Specification.new do |s|
s.required_ruby_version = '>= 3.0'
s.name = 'leetcode-ruby'
s.version = '8.3.0'
s.version = '8.3.1'
s.license = 'MIT'
s.files = ::Dir['lib/**/*.rb'] + %w[README.md]
s.executable = 'leetcode-ruby'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# frozen_string_literal: true

# https://leetcode.com/problems/maximum-nesting-depth-of-two-valid-parentheses-strings/
# @param {String} seq
# @return {Integer[]}
def max_depth_after_split(seq)
result = ::Array.new(seq.size)

seq.each_char.with_index do |char, i|
result[i] = char == '(' ? i & 1 : 1 - (i & 1)
end

result
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# frozen_string_literal: true

require_relative '../test_helper'
require_relative '../../lib/medium/1111_maximum_nesting_depth_of_two_valid_parentheses_strings'
require 'minitest/autorun'

class MaximumNestingDepthOfTwoValidParenthesesStringsTest < ::Minitest::Test
def test_default_one
assert_equal(
[0, 1, 1, 1, 1, 0],
max_depth_after_split(
'(()())'
)
)
end

def test_default_two
assert_equal(
[0, 0, 0, 1, 1, 0, 0, 0],
max_depth_after_split(
'()(())()'
)
)
end
end

0 comments on commit 2505c78

Please sign in to comment.