Skip to content

Commit 126dc95

Browse files
authored
Merge branch 'master' into ci-37
2 parents 9d9d7a3 + 3b8eabd commit 126dc95

File tree

5 files changed

+42
-1
lines changed

5 files changed

+42
-1
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,5 @@ Gemfile.lock
4242
# Version checker
4343
*.remote
4444

45+
# Cursor
4546
.cursor

README.md

+1
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

+1-1
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.1'
8+
s.version = '9.3.5.1'
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

+16
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
+23
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)