diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 3f2f95ac..b914c56f 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -7,7 +7,7 @@ on: branches: [ master ] env: - RUBY_VERSION: 3.0 + RUBY_VERSION: 3.3.6 SIMPLECOV_THRESHOLD: 100 jobs: diff --git a/leetcode-ruby.gemspec b/leetcode-ruby.gemspec index ad8f5d6a..882b5463 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 = '7.5.1' + s.version = '7.5.1.1' s.license = 'MIT' s.files = ::Dir['lib/**/*.rb'] + %w[README.md] s.executable = 'leetcode-ruby' diff --git a/lib/common/linked_list.rb b/lib/common/linked_list.rb index c94fdb82..333f1ced 100644 --- a/lib/common/linked_list.rb +++ b/lib/common/linked_list.rb @@ -29,9 +29,9 @@ def self.from_array(values) # @param {ListNode} second # @return {Boolean} def self.are_equals(first, second) - return true if first.nil? && second.nil? + return true if !first && !second - return false if first.nil? || second.nil? + return false if !first || !second first.val == second.val && are_equals(first.next, second.next) end diff --git a/lib/common/list_node_with_random.rb b/lib/common/list_node_with_random.rb index 07da5ae7..dbd73a40 100644 --- a/lib/common/list_node_with_random.rb +++ b/lib/common/list_node_with_random.rb @@ -26,6 +26,6 @@ def self.are_equal(l1, l2) l2 = l2.next end - l1.nil? && l2.nil? + !l1 && !l2 end end diff --git a/lib/common/next_tree_node.rb b/lib/common/next_tree_node.rb index 1475c19d..4611972a 100644 --- a/lib/common/next_tree_node.rb +++ b/lib/common/next_tree_node.rb @@ -25,7 +25,7 @@ def self.are_equals(n1, n2) return are_equals(n1.left, n2.left) && are_equals(n1.right, n2.right) end - n1.nil? && n2.nil? + !n1 && !n2 end # @param {NextTreeNode} other @@ -40,7 +40,5 @@ def ==(other) end # @return {Integer} - def hash - [val, left, right, nxt].hash - end + def hash = [val, left, right, nxt].hash end diff --git a/lib/common/node_with_neighbors.rb b/lib/common/node_with_neighbors.rb index e47bb667..086e4603 100644 --- a/lib/common/node_with_neighbors.rb +++ b/lib/common/node_with_neighbors.rb @@ -15,7 +15,7 @@ def initialize(val, neighbors = nil) # @param {NodeWithNeighbors} n2 # @return {Boolean} def self.are_equals(n1, n2) - if !n1.nil? && !n2.nil? + if n1 && n2 return false unless n1.val == n2.val return false unless n1.neighbors.size == n2.neighbors.size @@ -27,6 +27,6 @@ def self.are_equals(n1, n2) return true end - n1.nil? && n2.nil? + !n1 && !n2 end end