Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -673,3 +673,4 @@ Profile on LeetCode: [fartem](https://leetcode.com/fartem/).
| 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) |
| 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) |
| 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) |
| 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) |
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.0.3'
s.version = '8.0.4'
s.license = 'MIT'
s.files = ::Dir['lib/**/*.rb'] + %w[README.md]
s.executable = 'leetcode-ruby'
Expand Down
29 changes: 29 additions & 0 deletions lib/hard/1220_count_vowels_permutation.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# frozen_string_literal: false

# https://leetcode.com/problems/count-vowels-permutation/
# @param {Integer} n
# @return {Integer}
def count_vowel_permutation(n)
a = 1
e = 1
i = 1
o = 1
u = 1
mod = 10**9 + 7

(2..n).each do
a2 = (e + i + u) % mod
e2 = (a + i) % mod
i2 = (e + o) % mod
o2 = i
u2 = (o + i) % mod

a = a2
e = e2
i = i2
o = o2
u = u2
end

(a + e + i + o + u) % mod
end
13 changes: 13 additions & 0 deletions test/hard/test_1220_count_vowels_permutation.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: false

require_relative '../test_helper'
require_relative '../../lib/hard/1220_count_vowels_permutation'
require 'minitest/autorun'

class CountVowelsPermutationTest < ::Minitest::Test
def test_default_one = assert(5, count_vowel_permutation(1))

def test_default_two = assert(10, count_vowel_permutation(2))

def test_default_three = assert(68, count_vowel_permutation(5))
end
Loading