Skip to content

Commit 482ecdd

Browse files
authored
Merge pull request #650 from fartem/2549_Count_Distinct_Numbers_on_Board
2024-06-20 v. 5.9.3: added "2549. Count Distinct Numbers on Board"
2 parents 9dcf4c8 + e4a611f commit 482ecdd

4 files changed

+22
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,3 +453,4 @@ Profile on LeetCode: [fartem](https://leetcode.com/fartem/).
453453
| 2535. Difference Between Element Sum and Digit Sum of an Array | [Link](https://leetcode.com/problems/difference-between-element-sum-and-digit-sum-of-an-array/) | [Link](./lib/easy/2535_difference_between_element_sum_and_digit_sum_of_an_array.rb) |
454454
| 2540. Minimum Common Value | [Link](https://leetcode.com/problems/minimum-common-value/) | [Link](./lib/easy/2540_minimum_common_value.rb) |
455455
| 2544. Alternating Digit Sum | [Link](https://leetcode.com/problems/alternating-digit-sum/) | [Link](./lib/easy/2544_alternating_digit_sum.rb) |
456+
| 2549. Count Distinct Numbers on Board | [Link](https://leetcode.com/problems/count-distinct-numbers-on-board/) | [Link](./lib/easy/2549_count_distinct_numbers_on_board.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 = '5.9.2'
8+
s.version = '5.9.3'
99
s.license = 'MIT'
1010
s.files = ::Dir['lib/**/*.rb'] + %w[bin/leetcode-ruby README.md LICENSE]
1111
s.executable = 'leetcode-ruby'
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# frozen_string_literal: true
2+
3+
# https://leetcode.com/problems/count-distinct-numbers-on-board/
4+
# @param {Integer} n
5+
# @return {Integer}
6+
def distinct_integers(n)
7+
[1, n - 1].max
8+
end
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# frozen_string_literal: true
2+
3+
require_relative '../test_helper'
4+
require_relative '../../lib/easy/2549_count_distinct_numbers_on_board'
5+
require 'minitest/autorun'
6+
7+
class CountDistinctNumbersOnBoardTest < ::Minitest::Test
8+
def test_default
9+
assert_equal(4, distinct_integers(5))
10+
assert_equal(2, distinct_integers(3))
11+
end
12+
end

0 commit comments

Comments
 (0)