Skip to content

Commit 3443bff

Browse files
authored
2025-01-14 v. 8.0.4: added "1220. Count Vowels Permutation"
2 parents 1f3336e + 2fbf8a4 commit 3443bff

File tree

4 files changed

+44
-1
lines changed

4 files changed

+44
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -673,3 +673,4 @@ Profile on LeetCode: [fartem](https://leetcode.com/fartem/).
673673
| 936. Stamping The Sequence | [Link](https://leetcode.com/problems/stamping-the-sequence/) | [Link](./lib/hard/936_stamping_the_sequence.rb) | [Link](./test/hard/test_936_stamping_the_sequence.rb) |
674674
| 968. Binary Tree Cameras | [Link](https://leetcode.com/problems/binary-tree-cameras/) | [Link](./lib/hard/968_binary_tree_cameras.rb) | [Link](./test/hard/test_968_binary_tree_cameras.rb) |
675675
| 1106. Parsing A Boolean Expression | [Link](https://leetcode.com/problems/parsing-a-boolean-expression/) | [Link](./lib/hard/1106_parsing_a_boolean_expression.rb) | [Link](./test/hard/test_1106_parsing_a_boolean_expression.rb) |
676+
| 1220. Count Vowels Permutation | [Link](https://leetcode.com/problems/count-vowels-permutation/) | [Link](./lib/hard/1220_count_vowels_permutation.rb) | [Link](./test/hard/test_1220_count_vowels_permutation.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.0.3'
8+
s.version = '8.0.4'
99
s.license = 'MIT'
1010
s.files = ::Dir['lib/**/*.rb'] + %w[README.md]
1111
s.executable = 'leetcode-ruby'
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# frozen_string_literal: false
2+
3+
# https://leetcode.com/problems/count-vowels-permutation/
4+
# @param {Integer} n
5+
# @return {Integer}
6+
def count_vowel_permutation(n)
7+
a = 1
8+
e = 1
9+
i = 1
10+
o = 1
11+
u = 1
12+
mod = 10**9 + 7
13+
14+
(2..n).each do
15+
a2 = (e + i + u) % mod
16+
e2 = (a + i) % mod
17+
i2 = (e + o) % mod
18+
o2 = i
19+
u2 = (o + i) % mod
20+
21+
a = a2
22+
e = e2
23+
i = i2
24+
o = o2
25+
u = u2
26+
end
27+
28+
(a + e + i + o + u) % mod
29+
end
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# frozen_string_literal: false
2+
3+
require_relative '../test_helper'
4+
require_relative '../../lib/hard/1220_count_vowels_permutation'
5+
require 'minitest/autorun'
6+
7+
class CountVowelsPermutationTest < ::Minitest::Test
8+
def test_default_one = assert(5, count_vowel_permutation(1))
9+
10+
def test_default_two = assert(10, count_vowel_permutation(2))
11+
12+
def test_default_three = assert(68, count_vowel_permutation(5))
13+
end

0 commit comments

Comments
 (0)