Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit bb59ba6

Browse files
authored
2025年04月11日 v. 9.2.4: added "3151. Special Array I"
2 parents 600cbcf + 52ad60f commit bb59ba6

File tree

4 files changed

+49
-1
lines changed

4 files changed

+49
-1
lines changed

‎README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,7 @@ Profile on LeetCode: [fartem](https://leetcode.com/fartem/).
454454
| 2544. Alternating Digit Sum | [Link](https://leetcode.com/problems/alternating-digit-sum/) | [Link](./lib/easy/2544_alternating_digit_sum.rb) | [Link](./test/easy/test_2544_alternating_digit_sum.rb) |
455455
| 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) | [Link](./test/easy/test_2549_count_distinct_numbers_on_board.rb) |
456456
| 3110. Score of a String | [Link](https://leetcode.com/problems/score-of-a-string/) | [Link](./lib/easy/3110_score_of_a_string.rb) | [Link](./test/easy/test_3110_score_of_a_string.rb) |
457+
| 3151. Special Array I | [Link](https://leetcode.com/problems/special-array-i/) | [Link](./lib/easy/3151_special_array_i.rb) | [Link](./test/easy/test_3151_special_array_i.rb) |
457458
| 3498. Reverse Degree of a String | [Link](https://leetcode.com/problems/reverse-degree-of-a-string/) | [Link](./lib/easy/3498_reverse_degree_of_a_string.rb) | [Link](./test/easy/test_3498_reverse_degree_of_a_string.rb) |
458459

459460
### Medium

‎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 = '9.2.3'
8+
s.version = '9.2.4'
99
s.license = 'MIT'
1010
s.files = ::Dir['lib/**/*.rb'] + %w[README.md]
1111
s.executable = 'leetcode-ruby'

‎lib/easy/3151_special_array_i.rb‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# frozen_string_literal: true
2+
3+
# https://leetcode.com/problems/special-array-i/
4+
# @param {Integer[]} nums
5+
# @return {Boolean}
6+
def is_array_special(nums)
7+
return true if nums.size == 1
8+
9+
(0...nums.size - 1).each do |i|
10+
return false if nums[i].even? && nums[i + 1].even?
11+
12+
return false if nums[i].odd? && nums[i + 1].odd?
13+
end
14+
15+
true
16+
end
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# frozen_string_literal: true
2+
3+
require_relative '../test_helper'
4+
require_relative '../../lib/easy/3151_special_array_i'
5+
require 'minitest/autorun'
6+
7+
class SpecialArrayITest < ::Minitest::Test
8+
def test_default_one
9+
assert(
10+
is_array_special(
11+
[1]
12+
)
13+
)
14+
end
15+
16+
def test_default_two
17+
assert(
18+
is_array_special(
19+
[2, 1, 4]
20+
)
21+
)
22+
end
23+
24+
def test_default_three
25+
assert(
26+
!is_array_special(
27+
[4, 3, 1, 6]
28+
)
29+
)
30+
end
31+
end

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /