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 3bed269

Browse files
committed
2025年06月03日 v. 9.3.8: added "2678. Number of Senior Citizens"
1 parent 7574ea4 commit 3bed269

File tree

4 files changed

+42
-1
lines changed

4 files changed

+42
-1
lines changed

‎README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,7 @@ Profile on LeetCode: [fartem](https://leetcode.com/fartem/).
457457
| 2951. Find the Peaks | [Link](https://leetcode.com/problems/find-the-peaks/) | [Link](./lib/easy/2951_find_the_peaks.rb) | [Link](./test/easy/test_2951_find_the_peaks.rb) |
458458
| 2966. Divide Array Into Arrays With Max Difference | [Link](https://leetcode.com/problems/divide-array-into-arrays-with-max-difference/) | [Link](./lib/easy/2966_divide_array_into_arrays_with_max_difference.rb) | [Link](./test/easy/test_2966_divide_array_into_arrays_with_max_difference.rb) |
459459
| 2974. Minimum Number Game | [Link](https://leetcode.com/problems/minimum-number-game/) | [Link](./lib/easy/2974_minimum_number_game.rb) | [Link](./test/easy/test_2974_minimum_number_game.rb) |
460+
| 2678. Number of Senior Citizens | [Link](https://leetcode.com/problems/number-of-senior-citizens/) | [Link](./lib/easy/2678_number_of_senior_citizens.rb) | [Link](./test/easy/test_2678_number_of_senior_citizens.rb) |
460461
| 3046. Split the Array | [Link](https://leetcode.com/problems/split-the-array/) | [Link](./lib/easy/3046_split_the_array.rb) | [Link](./test/easy/test_3046_split_the_array.rb) |
461462
| 3083. Existence of a Substring in a String and Its Reverse | [Link](https://leetcode.com/problems/existence-of-a-substring-in-a-string-and-its-reverse/) | [Link](./lib/easy/3083_existence_of_a_substring_in_a_string_and_its_reverse.rb) | [Link](./test/easy/test_3083_existence_of_a_substring_in_a_string_and_its_reverse.rb) |
462463
| 3090. Maximum Length Substring With Two Occurrences | [Link](https://leetcode.com/problems/maximum-length-substring-with-two-occurrences/) | [Link](./lib/easy/3090_maximum_length_substring_with_two_occurrences.rb) | [Link](./test/easy/test_3090_maximum_length_substring_with_two_occurrences.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 = '9.3.7.1'
8+
s.version = '9.3.8'
99
s.license = 'MIT'
1010
s.files = ::Dir['lib/**/*.rb'] + %w[README.md]
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/number-of-senior-citizens/
4+
# @param {String[]} details
5+
# @return {Integer}
6+
def count_seniors(details)
7+
details.count { |detail| detail[11..12] > '60' }
8+
end
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# frozen_string_literal: true
2+
3+
require_relative '../test_helper'
4+
require_relative '../../lib/easy/2678_number_of_senior_citizens'
5+
require 'minitest/autorun'
6+
7+
class NumberOfSeniorCitizensTest < ::Minitest::Test
8+
def test_default_one
9+
assert_equal(
10+
2,
11+
count_seniors(
12+
%w[
13+
7868190130M7522
14+
5303914400F9211
15+
9273338290F4010
16+
]
17+
)
18+
)
19+
end
20+
21+
def test_default_two
22+
assert_equal(
23+
0,
24+
count_seniors(
25+
%w[
26+
1313579440F2036
27+
2921522980M564
28+
]
29+
)
30+
)
31+
end
32+
end

0 commit comments

Comments
(0)

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