diff --git a/README.md b/README.md index 30ddf934..0753db13 100644 --- a/README.md +++ b/README.md @@ -707,6 +707,7 @@ Profile on LeetCode: [fartem](https://leetcode.com/fartem/). | 1557. Minimum Number of Vertices to Reach All Nodes | [Link](https://leetcode.com/problems/minimum-number-of-vertices-to-reach-all-nodes/) | [Link](./lib/medium/1557_minimum_number_of_vertices_to_reach_all_nodes.rb) | [Link](./test/medium/test_1557_minimum_number_of_vertices_to_reach_all_nodes.rb) | | 1609. Even Odd Tree | [Link](https://leetcode.com/problems/even-odd-tree/) | [Link](./lib/medium/1609_even_odd_tree.rb) | [Link](./test/medium/test_1609_even_odd_tree.rb) | | 1630. Arithmetic Subarrays | [Link](https://leetcode.com/problems/arithmetic-subarrays/) | [Link](./lib/medium/1630_arithmetic_subarrays.rb) | [Link](./test/medium/test_1630_arithmetic_subarrays.rb) | +| 1641. Count Sorted Vowel Strings | [Link](https://leetcode.com/problems/count-sorted-vowel-strings/) | [Link](./lib/medium/1641_count_sorted_vowel_strings.rb) | [Link](./test/medium/test_1641_count_sorted_vowel_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) | | 2429. Minimize XOR | [Link](https://leetcode.com/problems/minimize-xor/) | [Link](./lib/medium/2429_minimize_xor.rb) | [Link](./test/medium/test_2429_minimize_xor.rb) | diff --git a/leetcode-ruby.gemspec b/leetcode-ruby.gemspec index b3af6069..dcdaddce 100644 --- a/leetcode-ruby.gemspec +++ b/leetcode-ruby.gemspec @@ -5,7 +5,7 @@ require 'English' ::Gem::Specification.new do |s| s.required_ruby_version = '>= 3.0' s.name = 'leetcode-ruby' - s.version = '8.7.3' + s.version = '8.7.4' s.license = 'MIT' s.files = ::Dir['lib/**/*.rb'] + %w[README.md] s.executable = 'leetcode-ruby' diff --git a/lib/medium/1641_count_sorted_vowel_strings.rb b/lib/medium/1641_count_sorted_vowel_strings.rb new file mode 100644 index 00000000..041169e1 --- /dev/null +++ b/lib/medium/1641_count_sorted_vowel_strings.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +# https://leetcode.com/problems/count-sorted-vowel-strings/ +# @param {Integer} n +# @return {Integer} +def count_vowel_strings(n) + (n + 4) * (n + 3) * (n + 2) * (n + 1) / 24 +end diff --git a/test/medium/test_1641_count_sorted_vowel_strings.rb b/test/medium/test_1641_count_sorted_vowel_strings.rb new file mode 100644 index 00000000..74aae3f6 --- /dev/null +++ b/test/medium/test_1641_count_sorted_vowel_strings.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +require_relative '../test_helper' +require_relative '../../lib/medium/1641_count_sorted_vowel_strings' +require 'minitest/autorun' + +class CountSortedVowelStringsTest < ::Minitest::Test + def test_default_one = assert_equal(5, count_vowel_strings(1)) + + def test_default_two = assert_equal(15, count_vowel_strings(2)) + + def test_default_three = assert_equal(66_045, count_vowel_strings(33)) +end