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

Browse files
authored
Merge pull request #1025 from fartem/3046-Split-the-Array
2025年04月28日 v. 9.3.5: added "3046. Split the Array"
2 parents c905ca4 + a677991 commit 3b8eabd

File tree

5 files changed

+44
-1
lines changed

5 files changed

+44
-1
lines changed

‎.gitignore‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,6 @@ Gemfile.lock
4141

4242
# Version checker
4343
*.remote
44+
45+
# Cursor
46+
.cursor

‎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+
| 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) |
460461
| 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) |
461462
| 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) |
462463
| 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) |

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

‎lib/easy/3046_split_the_array.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/split-the-array/
4+
# @param {Integer[]} nums
5+
# @return {Boolean}
6+
def is_possible_to_split(nums)
7+
count = {}
8+
9+
nums.each do |num|
10+
count[num] = count.fetch(num, 0) + 1
11+
12+
return false if count[num] == 3
13+
end
14+
15+
true
16+
end
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# frozen_string_literal: true
2+
3+
require_relative '../test_helper'
4+
require_relative '../../lib/easy/3046_split_the_array'
5+
require 'minitest/autorun'
6+
7+
class SplitTheArrayTest < ::Minitest::Test
8+
def test_default_one
9+
assert(
10+
is_possible_to_split(
11+
[1, 1, 2, 2, 3, 4]
12+
)
13+
)
14+
end
15+
16+
def test_default_two
17+
assert(
18+
!is_substring_present(
19+
[1, 1, 1, 1]
20+
)
21+
)
22+
end
23+
end

0 commit comments

Comments
(0)

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